John_John Posted April 24, 2012 Share Posted April 24, 2012 Hi all, There are times where i need some text to appear translated but cannot be maintained through the system. I know there are ways to include certain pieces of code depending on page name, for example: {if $page_name == 'index'} <p>Only appears on the index file</p> {/if} But are there ways to include text like this based on the language? Lets say the site has 3 languages, English, Spanish, French "If" language is "EN" then <p>this text should only appear when English is selected</p> "If" language is "ES" then <p>this text should only appear when Spanish is selected</p> "If" language is "FR" then <p>this text should only appear when French is selected</p> Hope it makes sense, thanks Link to comment Share on other sites More sharing options...
Mike Kranzler Posted April 24, 2012 Share Posted April 24, 2012 Hi John_John, You can actually do this very easily in your store's Back Office. In this situation, all you need to do is click on the little flag next to each text field (such as Short or Long Description), and then you can provide alternative text in each individual language. I hope this helps. -Mike Link to comment Share on other sites More sharing options...
John_John Posted April 24, 2012 Author Share Posted April 24, 2012 Hi Mike, Thanks for your answer. Although that would work for normal pages and such....what if i had custom text that are not connected to the Back Office? How would i be able to code it in such a way that it still changes according to which language is selected at that time? Link to comment Share on other sites More sharing options...
Mike Kranzler Posted April 24, 2012 Share Posted April 24, 2012 Hi Mike, Thanks for your answer. Although that would work for normal pages and such....what if i had custom text that are not connected to the Back Office? How would i be able to code it in such a way that it still changes according to which language is selected at that time? Hi John_John, Can you please give me an example of this sort of text so that I can look into it for you? -Mike Link to comment Share on other sites More sharing options...
John_John Posted April 24, 2012 Author Share Posted April 24, 2012 Well, its rather simple.. In the header.tpl you would find code like this: {if $page_name == 'index'} <p>Only appears on the index file</p> {/if} Meaning that the paragraph will only appear when its on the index file. I just want something similar but based on the selected language. So for example: the site has 3 languages, English, Spanish, French "If" language is "EN" then <p>this text should only appear when English is selected</p> Else "If" language is "ES" then <p>this text should only appear when Spanish is selected</p> Else "If" language is "FR" then <p>this text should only appear when French is selected</p> Thing is, i just dont know how to write the correct piece of code that would allow the above to work Link to comment Share on other sites More sharing options...
Mike Kranzler Posted April 24, 2012 Share Posted April 24, 2012 Hi John_John, Can you please post a link where I can see this for myself on your site? I want to make sure I can better visualize how you want it to appear before giving you any suggestions for this. -Mike Link to comment Share on other sites More sharing options...
John_John Posted April 26, 2012 Author Share Posted April 26, 2012 Hi Mike, Here is a test, goto www.trendyhk.com (a dummy website) In the center column you will see this sentence: "This is some sample text that needs to change according to the selected langauge and this piece of text is not managed through the backend but coded hard into the code" I would like this text to change according to language Thanks Link to comment Share on other sites More sharing options...
Mike Kranzler Posted April 26, 2012 Share Posted April 26, 2012 Hi John_John, Go ahead and try using this code: {if $lang_iso == 'en'} Hello {elseif $lang_iso == 'fr'} Bonjour {elseif $lang_iso == 'es'} Hola {/if} Please let me know if this works for you. -Mike 3 Link to comment Share on other sites More sharing options...
John_John Posted April 26, 2012 Author Share Posted April 26, 2012 Mike, that is perfect Link to comment Share on other sites More sharing options...
Mike Kranzler Posted April 26, 2012 Share Posted April 26, 2012 I'm glad I could help! I'll go ahead and mark this thread as solved for you. Happy selling! -Mike Link to comment Share on other sites More sharing options...
Recommended Posts