Forum OpenACS Q&A: ACS-LANG

Collapse
Posted by Iuri Sampaio on
I'm trying to figure out what is the variable that is sent to the pages to make the translation of the text.

I want to make a if tag, to change the header of the page acording to the language the user selected.
Does anyone have a clue of that?

Collapse
2: Re: ACS-LANG (response to 1)
Posted by Iuri Sampaio on
Sorry for ask!

I already figure out. If are interested on what i did, look at.
I have the site on 4 languages, and i want to put one header for each language. So i made that to do the job and choose waht image is to post. The i don't need to change the whole page!!

#----------------------------------------------------------------------
# Setting Language
#----------------------------------------------------------------------

set language [lang::user::language]

if { [string equal $language "us"] } {
set aux_lang 0
} else {
if { [string equal $language "es"] } {
set aux_lang 1
} else {
if { [string equal $language "pt"] } {
set aux_lang 2
} else {
if { [string equal $language "fr"] } {
set aux_lang 3
}
}
}

Collapse
3: Re: ACS-LANG (response to 1)
Posted by Dave Bauer on
Read the internationalization documentation. It explains how to setup message keys to automatically output the correct content based on the user's preferred language. You should not need any special code within a page to support this.

https://openacs.org/doc/openacs-5-2/i18n.html

Collapse
4: Re: Re: ACS-LANG (response to 3)
Posted by Iuri Sampaio on
I know, but on this case, it's a header. I mean it's a image abd the I98n is just for messages.

By the way...
can a message be an image??

Collapse
5: Re: ACS-LANG (response to 1)
Posted by Dave Bauer on
The message would contain the HTML to display the image.

like

<img src="/images/en_US_whatever.jpg">

You can embed any HTML In the message. You can refer to variables available in the page as well by surrounding the variable name with % ie: %varname%

In this case it might not be a big win to use acs-lang but instead of your complex switch statement I would name the images with the locale so you can do something like

img src="@mailto:user_locale@_image_name.jpg";

or place them in a folder by locale

img src="/images/@mailto:user_locale@/image_name.jpg";

This is more flexible. It would be interesting to discuss other ways to abstract this type of user interface element. I still think its probably best to use the message keys, then all your localization is done in one place.

Collapse
6: Re: Re: ACS-LANG (response to 5)
Posted by Iuri Sampaio on
I will read the I98n docs first of all.
Just give me time to abstract that.