Internationalization/developer manual

Revision as of 06:57, 21 June 2006 by Trosim (Talk | contribs) (How to use the library)


Developer manual

How to design the software

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.png Warning: You should not load a new source or structure after the call to i18n_load, or the system will break.

Localization

How to translate / use translation files