Difference between revisions of "Modules/localize"

From MSX Game Library

< Modules

Line 6: Line 6:
 
* A file (or several) in which the user places his translations for each supported language in the form: <tt>key = "text"</tt>.
 
* A file (or several) in which the user places his translations for each supported language in the form: <tt>key = "text"</tt>.
 
* A project configuration (See [[Modules/localize#Settings|bellow]]) to inform the Build tool of the translation files to be processed.
 
* A project configuration (See [[Modules/localize#Settings|bellow]]) to inform the Build tool of the translation files to be processed.
* A module to be initialized in the code, then functions to be used to retrieve a given text in the selected language.
+
* A module to be initialized in the code, then functions to select a language and to retrieve a given text.
  
 
== Dependencies ==
 
== Dependencies ==

Revision as of 12:12, 24 November 2023

The localize module handle translation in several langage of your application. This module is very small in size and very efficient.

Usage

The translation process consists of 3 elements:

  • A file (or several) in which the user places his translations for each supported language in the form: key = "text".
  • A project configuration (See bellow) to inform the Build tool of the translation files to be processed.
  • A module to be initialized in the code, then functions to select a language and to retrieve a given text.

Dependencies

Dependency on other modules: None.

Settings

The localization process can be customized in your Build tool configuration file, project_config.js:

//-- List files to be localized (array)
LocFiles = [ "file1.ini", "file2.ini" ];

//-- Localization output filename (string)
LocOutput = "localization.h";

//-- Localization structure name (string)
LocStruct = "g_LocData";

Note: If LocFiles is empty (default value), the localization process is disabled.

Appendix

  • See also: Sample program s_loc

Documentation