> So now I'm planning to use a 4D table "localized_text", where I (or someone
> speaking the foreign language) can add phrases in different languages. On
> application start, I'll load the whole table in a global collection. Then
> I'd replace all static text, aka. "Invoice" with  <%=invoice["de"]%>,
> <%=invoice["fr"]%> etc.

I created a library with a getLocalizedText($tag) method that would do the 
following:

1. Check the cookies for a user-configured language.
2. If #1 fails, check the Accept-Language header.
3. If #2 fails, default to "en".
4. Return self{"localized_text"}{$language}{$tag}

$tag is an identifier for the text, such as "invoice". You may also want to 
deal with specializations of a language falling back to the main language, such 
as "en-br".

The __load__ method of the library does the following:

1. Create a global collection in self{"localized_text"}.
2. For each language, create an item keyed on the language code whose value is 
a global collection.
3. For each language code collection, create an item for each localized text, 
keyed on its tag, whose value is the localized text.

In the __unload__ method, do deep clear collection(self{"localized_text"}.

Regards,

   Aparajita
   www.aparajitaworld.com

   "If you dare to fail, you are bound to succeed."
   - Sri Chinmoy   |   www.srichinmoy.org

_______________________________________________
Active4D-dev mailing list
[email protected]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/

Reply via email to