Project

General

Profile

Scol standard library package  0.3.1
Common and usefull functions for all Scol applications
loc.pkg File Reference

Localization API. More...

Functions

 findloc (l, s)
 loadloc (file, lang)
 loc (s)
 loc_check ()
 loc_clear ()
 Clear the current localisation. It should be used before to reload a language file.
 loc_findloc (list, s)
 loc_get (ref)
 Return the translation of a given reference. If the reference is not found, the "unknown string" (see below) is returned.
 loc_getDefaultLang ()
 Get the default language. By default, it is "english".
 loc_getDefaultParamSymbol ()
 Return the default symbol for parameters.
 loc_getLang ()
 Get the language used by this client.
 loc_gets (ref, listParam)
 Return the translation of a given reference. If the reference is not found, the "unknown string" (see below) is returned.
 loc_gets2 (s, listParam)
 loc_getUnknown ()
 Get the returned string when no reference is found. By default, it is "*".
 loc_hachage (ref)
 loc_init (file)
 Initialize and load the language file The language is the favorite language defined in the Scol settings by the client. If not found, the default language is taken off.
 loc_initEx (file, lang)
 Initialize and load the language file The language is forced (the Scol settings choice is skipped) If not found, the default language is taken off.
 loc_isLoaded ()
 Return if a language is currently loaded.
 loc_loadloc (file, lang)
 loc_loadloc2 (list)
 loc_rebuild (list)
 loc_setDefaultParamSymbol (str)
 Set the default symbol for parameters. The language file should not be loaded yet. * By default, it is "##".
 loc_setLangDefault (str)
 Set the language default. By default, it is "english". It should be only called before loc_init or loc_initEx and after, if any, loc_clear.
 loc_setUnknown (str)
 Set the returned string when no reference is found. By default, it is "*".
 startloc (file)
 strloc (s, l)

Variables

typeof loc_tabLoc = tab [[S S] r1]
var locDefaultlang = "english"
var locDefaultParam = "##"
var locDefaultParamSize = 2
typeof locLang = S
var locOk = 0
var locUnknown = "*"

Detailed Description

Localization API.

Author
Scol team
Version
0.2

This API provides a method to internationalize an application.

Translators and/or contributors can easily give a translation.

For an application, a sub directory is created. Within are the translations. Each translations are named myapp.<language>.lang. For example :

myapp.english.lang
myapp.french.lang
myapp.russian.lang
myapp.spanish.lang
...

In each file, a list of reference and translations :

REFERENCE_1 word_translated
REFERENCE_2 string translated
REFERENCE_3 substring_1 ## substring_2 ## substring_3
...

Each ## will be replaced by a provided parameter, if needed. You can change this symbol as you want, see below.

  • loc_init is the function to load the language file for a given user.
  • loc_get is the function for a simple translation.
  • loc_gets loc are the functions for a translation with parameters

See http://redmine.scolring.org/projects/tutorials/wiki/How_to_localize_a_program_in_Scol