Magic User Group

Magic Wiki-Wakka : Take

HomePage :: CATEGORIES | Index :: Changes :: Comments :: Search :: Login/Register
Oldest known version of this page was edited on 2009-02-06 22:48:36 by InformaPlus [MLS Details]
Page view:

Multi-Lingual Support MLS first step:


The following provides a guideline for someone who never used the Multi-Language Support (MLS) feature of Magic and wishes to try it for the first time:

1) Make yourself a simple Magic online "Hello World" program with a text control on the form stating “Hello World” and an “<OK>” button to exit the program.

2) With Notepad (or any text editor), in the directory where Magic executable resides, create a small text file called '<Language>.txt' for example: French.txt with two lines in the file as:
Hello World (on the first line)
Allo monde (on the second line)
Save and close that file.

3) Use 'mls_bld.exe' program on the Magic folder from some DOS command prompt to convert the above text file to a <Language>.dat file. For example:
From the command prompt, on the magic folder where both the mls_bld.exe utility and previous text file may reside, you may type:
mls_bld <source> <destination> or for example:
mls_bld French.txt French.dat

4) Use 'Settings/Languages' to configure your ' language as pointing to the <destination> result above. For example:
Having line in this table for the 'French' language configured to 'French.dat'

5) Now to activate the French language in this example:
Go to 'Settings/Environment/External/Starting Language' and Zoom and assign this setting to the previously configured language.

6) Run the "Hello World" program again.
Voila! It is now the "Allo monde" program.

7 ) OK, You are somewhere but. What about expressions?
As straight text into expressions will not be translated, you now have to use the Mlstrans() function around any text that you wish to be translated in your expressions.

With V10 and UniPaaS, it is also a good idea to consider the StrBuild() function

Example:

StrBuild ('Hello @1@, You have @2@ reports',A,str(B,'5'))
when A='World' and B=20, the function returns: 'Hello World, You have 20 reports'.
This example can replace the following concatenated expression:
'Hello '&Trim(A)&', You have '&Trim(Str(B,'5'))&'reports'.

Ultimately:
StrBuild (Mlstrans('Hello @1@, You have @2@ reports'),A,str(B,'5'))
Will allow very flexible translations where the parameters position can vary between the original language and translated to language.

8) How to extract all the literals to translate from your entire application?

For V10 and UniPaaS, there is a string extractor utility:
From the Studio with the project opened: Tools/String Extractor

For V9 and previous versions you can either:

a) Write yourself a Magic Program that reads the export of your application and extracts (figuring out the tags) the literals. It will take you a while and the result will be version specific, but it is not rocket science.

b) Use an existing third party utility for this. Such as the 'optimizer' utility offered by Ocean Solutions at: http://www.magic-optimizer.com/.

c) Just convert your V9 application to UniPaaS for the purpose of using the String Extractor in V10 while using the result in V9 to continue in V9.

9) Get acquainted with other language related functions such as:
GetLang()
SetLang()

10) The above points pretty much cover what the Magic environment has to offer. However, you might also need to consider if your application needs to be multi-lingual within itself. In such case, data fields and/or data tables might need to be defined for various languages and logic implemented to use the proper language data val9ues for the language to apply for a particular program in a particular application context.

That is about it in a nutshell,

This page was produced by: Informaplus
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki trunk
Page was generated in 0.0566 seconds