Jump to content

Recommended Posts

<?xml version="1.0" encoding="utf-8"?>
<home>
   <firstHeader>Welcome to my Site</firstHeader>
   <firstParagraph>You are here because your not there.</firstParagraph>
   <secondParagraph>You are Ugly because we are beautiful</secondParagraph>
   <thirdParagraph>If there no ugly people then there is no beautul people.</secondParagraph>
   <question>Make sense right?</question>
</home>

How do I translate the data of the xml file to other language? Anyones have an idea? or what tools should I use?

Link to comment
https://forums.phpfreaks.com/topic/278879-change-language-of-xml-data/
Share on other sites

Sorry, I think my question is wrong. I'll going to try more specifically. 

 

I'm using codeigniter and it has already have a built in function on localization, but using codeigniter it will take more and more time to translate  the language each page, so if you have a 30 language and my boss said that it is not frexible if we have many sites. My boss said that we can use XML on that to change the language. (What I understand is every page has it own XML file. e.g. home.xml, about.xml etc. . and that is were all the information of the page came from). . 

 

So what really my question is, how can I change the content of each XML file to other language. . e.g. to russian. . some like you will convert the data on the XML file. or other question is, It is possible?

 

I don't really know about XML. . 

You can't do it just by editing XML. There has to be some code somewhere to handle the translations.

 

I would structure the XML like

<?xml version="1.0" encoding="utf-8"?>
<home>
	<translation lang="en-us">
		<firstHeader>Welcome to my Site</firstHeader>
		<firstParagraph>You are here because your not there.</firstParagraph>
		<secondParagraph>You are Ugly because we are beautiful</secondParagraph>
		<thirdParagraph>If there no ugly people then there is no beautul people.</secondParagraph>
		<question>Make sense right?</question>
	</translation>
	<translation lang="leet">
		<firstHeader>VV3|_(0/\/\3 70 /\/\`/ 5173</firstHeader>
		<firstParagraph>I don't have the patience to translate the rest of them</firstParagraph>
		<secondParagraph>An insult</secondParagraph>
		<thirdParagraph>Some kind of justification for you not killing yourself even though you're so ugly</thirdParagraph>
		<question>Is your site full of snobs or is it just you?</question>
	</translation>
</home>

 

 

I would structure the XML like

 

That is what I'm also thinking but that`s the same logic as the codeigniter built function, so if you have a bunch of language then will going to translate it several times also. I think that is the best and easy option we have.

 

 

 

There has to be some code somewhere to handle the translations.

Do you have any idea or where can I study it to know how. ?

I'm pretty sure this is the second time you've asked this question and once again haven't been clear about it. Both times its appeared as thought you want to translate a document on-the-fly, think about what you're writing in future and even more so if English isn't your first language. The better we understand, the better we can help.

 

Regarding your question: requinix's answer is the best you'll get. When someone sends a request to your server for the first time, set a default language to use - you could potentially set it based on the IP origin although this will be somewhat inaccurate. Store the language in a cookie for future use (Assuming you've got permission. If not, just set a session). Then overwrite the cookie/session each time they select a new language.

 

You can then retrieve the content from your XML file based on the language they have selected, format the text however and serve up the formatted content.

 

Client              Server            FileSystem 
   |                   |                   |
   | First Request     |                   |
   |------------------>|                   |
   |              SetDefaLang              |
   |                   |                   |
   |                   |   GetXMLContent   |
   |                   |------------------>|
   |                   |                   |
   |                   |     Content       |
   |                   |<------------------|
   |                   |                   |
   |              SelectLang               |
   |                   |                   |
   |SendContentWithCookie                  |
   |<------------------|                   |
   |                   |                   |
   |                   |                   |
   |SecReqWithLangCookie                   |
   |------------------>|                   |
   |           UseCookieToGetContent       |
   |                   |                   |
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.