Difference between revisions of "Internationalization/developer manual"
m (Cosmetics) |
m (→How to design the software) |
||
Line 2: | Line 2: | ||
= How to design the software = | = How to design the software = | ||
+ | There is only a few things which can help you using our library, the most important one is dividing completely the logic of the program from the content. | ||
+ | In other words, you should write a class which contains all the strings you use in the program; so applying out system will be very easy. | ||
= How to use the library = | = How to use the library = |
Revision as of 09:40, 25 June 2006
Contents
How to design the software
There is only a few things which can help you using our library, the most important one is dividing completely the logic of the program from the content. In other words, you should write a class which contains all the strings you use in the program; so applying out system will be very easy.
How to use the library
Here you can find instructions on how to use our library; how to initialize the system and how to make the translations actually appear in your application.
Initialization
To initialize the library you should have a class that inherits from the SHARED_I18N_LOCALIZATOR; this will bring you all the necessary infrastructure to start localizing your software.
What to do?
- create datasource
- create datastructure
- load localizator
Creating a datasource
We equip you with a simple factory to create the sources, simply create an I18N_DATASOURCE_FACTORY
datasource_factory: I18N_DATASOURCE_FACTORY create datasource_factory.make
you now have the possibility to create a new source based on an mo file, as follows
datasource: I18N_DATASOURCE datasource_factory.use_mo_file(mo_file_path) if datasource_factory.last_datasource /= Void then datasource := datasource_factory.last_datasource end
if something went wrong, you can alway fallback with an empty datasource
datasource_factory.use_empty_source datasource := datasource_factory.last_datasource
The datasource is ready, you should create a datastructure for storing the strings.
Creating a datastructure
We provide you with a simple factory to create datastructures, so follow the example
datastructure_factory: I18N_DATASTRUCTURE_FACTORY create datastructure_factory.make
You can now create, for example, an hash table
datastructure: I18N_DATASTRUCTURE datastructure_factory.use_hash_table if datastructure_factory.last_datastructure /= Void then datastructure := datastructure_factory.last_datastructure end
and, even in this case, if something went wrong, you can create a dummy datastructure
datastructure_factory.use_dummy datastructure := datastructure_factory.last_datastructure
Now that you have the datastructure ready, you can load the localizator.
Loading the localizator
It's important that you do this part before trying to localize any string, if not, the localizator would serve you what you pass as argument.
Pass the source to the localizator
i18n_use_datasource(datasource)
then pass the datastructure
i18n_use_datastructure(datastructure)
and finally load the localizator with the new source and structure
i18n_load
You now have a working localization environment!
Warning: If you don't assign a source AND a structure AND then call load, the system will continue to use the old ones.