Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
WMFGREEN #1
Member since Jan 2012 · 20 posts
Group memberships: Members
Show profile · Link to this post
Subject: lang attribute in xml
             Hello again,
 
        Is there a way to force the lang attribute to a certain language when sending/receiving xml blocks?
       
       
  1.         <stream:stream xmlns:stream=... id=... from=... version="1.0" xml:lang="en" >

        For example in the xml code line above I have lang="en". Can I force it to always be lang="en"?
       Sometimes the language is not english. I don't know how or when this happens but I was wandering if I can force language to     always be english.

        Thank you in advance.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by WMFGREEN:
Is there a way to force the lang attribute to a certain language when sending/receiving xml blocks?

XmppXElement has a property named XmlLanguage. There you can set the language of your packets.

Quote by WMFGREEN:
  1. <stream:stream xmlns:stream=... id=... from=... version="1.0" xml:lang="en" >

The incoming stream header gets created by your server, and MatriX show the xml:lang attribute your server sends.
The outgoing stream header is created by MatriX, there is currently no way to override it.

Alex
Avatar
WMFGREEN #3
Member since Jan 2012 · 20 posts
Group memberships: Members
Show profile · Link to this post
           Can you also please tell me where should I set this property?

           Thank you
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you don't have to set it at all. It makes only sense to use it when

  • 1) your server supports multiple languages and can presents content in the choosen language. Under "normal" conditions you don't need it.
  • 2) you want to send eg. a message in multiple langauges like the following

  1. <message xml:lang='fr' from='bard@shakespeare.lit/globe' to='playwright@marlowe.lit/theatre'>
  2.  <subject xml:lang='fr'>Bonjour</subject>
  3.  <subject xml:lang='en'>Hello</subject>
  4.  <subject xml:lang='ru'>x443;&#x43B;&#x442;&#x435;</subject>
  5.  <body xml:lang='fr'>comment allez-vous?</body>
  6.  <body xml:lang='en'>How are you?</body>
  7.  <body xml:lang='ru'>&#x41A;&#x430;&#x43A; &#x432;&#x44B;?</body>
  8. </message>
Avatar
WMFGREEN #5
Member since Jan 2012 · 20 posts
Group memberships: Members
Show profile · Link to this post
          But I need all xml exchanges to have lang="en".
          For example the xml exchange when I use the Open() method within the XmppClient object.
          How do I do this? Is there a way to do this from my client application?
          Thank you.
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by WMFGREEN:
But I need all xml exchanges to have lang="en".

why do you need this? Please elaborate.

Quote by WMFGREEN:
For example the xml exchange when I use the Open() method within the XmppClient object.
How do I do this? Is there a way to do this from my client application?

On all packets you send with XmppCLient.Send() you can add it with the following code.

  1. var msg = new Message();
  2. // fill properties
  3. msg.XmlLanguage = "en";
  4. XmppClient.Send(msg)

You cannot add it to the stream header.
Avatar
WMFGREEN #7
Member since Jan 2012 · 20 posts
Group memberships: Members
Show profile · Link to this post
          I am a .NET Developer and I've been assigned this task.
          When the XmppClient initiates connection to the XMPP server with the Open() method an xml exchange occurs. Right?
          I need this exchange to have lang="en". And all other exchanges that have the lang attribute.
          At the moment I don't know why we need this, it's just what I was asked to do.
          Thank you for your time.
Avatar
WMFGREEN #8
Member since Jan 2012 · 20 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #6
So I cannot set the XmppClient.Open() xml exchange to english, right?
Avatar
WMFGREEN #9
Member since Jan 2012 · 20 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #6
How about presence? Can I set it there? For example:
  1. <presence xml:lang="fr" />
Avatar
Alex #10
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #8
Quote by WMFGREEN:
So I cannot set the XmppClient.Open() xml exchange to english, right?

XmppClient.Open() does lots of stuff until your are logged in.
As said before you can set the xml lang on every packet you sent. But you cannot set it to the stream header. And I currently see no reasons for changes until you can t can give me a good reason or tell me under which conditions this causes problem.

Quote by WMFGREEN:
I've been assigned this task.
this is not a good reason for me ;-)
Avatar
Alex #11
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #9
Quote by WMFGREEN:
How about presence? Can I set it there? For example:
  1. <presence xml:lang="fr" />

Please read my posts, I have given you an example for this before.

Alex
Avatar
WMFGREEN #12
Member since Jan 2012 · 20 posts
Group memberships: Members
Show profile · Link to this post
Ok, thank you.
I think I got it.
I guess we will have to leave it as it is regarding the stream header.
Avatar
WMFGREEN #13
Member since Jan 2012 · 20 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #11
Thank you very much.
I've seen that there is a property Presence.XmlLanguage as you previously instructed me.
I talked to my team leader and he said it is ok if I don't fix the issue entirely. (not a major issue probably)
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters: