Jump to content

[SOLVED] Custom text based on selected language


Recommended Posts

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

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

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

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

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

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

×
×
  • Create New...