>>>You can create a regular caption and call your function in Label's init, e.g.
>>>
>>>this.caption = TranslateWord(this.caption)
>>
>>You are GENIUS !!! Thanks!!!
>
>Only... I wouldn't put that in the .init(), because it happens only once. Want to change the language, close and reload... not too comfortable. Since the language change is something that happens across the whole app, it may be worthwhile to have a .decorate() method in each of your base classes that may display text (labels, checkboxes, combos, textboxes etc), and call that on all controls. It may not only translate (translation may apply only to those with a .caption), but also change .fontCharSet property, LTR/RTL, .dateformat, .DateMark etc.
>
>When translating, you'll have a big problem if you're starting with english first, simply because the same word may translate several ways into other languages, or the same phrase may have a different order of words (and you want to merge that). Two simple examples:
>
>- you have a button with .caption="Purchase" and a column header with the same. However, in the first case, it's a verb (commandbuttons generally represent action), and in the second it's a noun (what's in this column?). The verb and the noun are, in most languages, different words. You will need two or more entries in your dictionary table, and a way to know which record to use in each context. Perhaps have "purchase, v" translate into "Purchase" (english), "kupi" (serbian), "vasárolj" (hungarian), "покупи" (russian), and "purchase, n" translate into "Purchase" (english), "pazar" (serbian), "vasárolt" (hungarian), "покупка" (russian, if I got this one right). And mind you, this is for a commandbutton, where it means "do buy" - in a case of "what do you want to do: purchase/sell", it is not in imperative mode anymore, it's more of an infinitive, you need a "to purchase" record which translates into "Purchase","da kupim", "vasárolni", "покупитъ".
>
>- you have a messagebox saying "could not find the"+ cFname+" file". I know at least two languages where the file name would not be in that place in the sentence (not to mention that "file" is again a verb and a noun and sometimes an adjective). The best solution I've found so far is to have a merged parameter, something like "could not find the % file", which then translates as "nem találhatom a %1 fajlt" (hungarian), "nisam našao fajl %1" (serbian), and you call the function with translate("could not find the % file", cFname).
Dragan,
покупи" (russian) -- this is incorrect. There is no such word in Russian. Kypi is a word, but I doubt it's used in the forms. May be the whole 'Purchase' example is not very good, as I don't remember having button saying Purchase in English forms either.
I am thinking we will use present indefinite form in Russian, so it will be 'Kupit' '
"покупитъ". -- no such word in Russian, correct one is
"купитъ".
If it's not broken, fix it until it is.
My Blog