![]() |
Scol standard library package
0.3.1
Common and usefull functions for all Scol applications
|
Functions | |
| loc_clear () | |
| Clear the current localisation. It should be used before to reload a language file. | |
| 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_getUnknown () | |
| Get the returned string when no reference is found. By default, it is "*". | |
| 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_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 "*". | |
Detailed Description
This API provides a way to localize (internationalize) strings. 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
Package to load : lib/loc/loc.pkg
Function Documentation
| loc_get | ( | ref | ) |
Return the translation of a given reference. If the reference is not found, the "unknown string" (see below) is returned.
- See Also
- loc_setUnknown
- loc_getUnknown
Prototype: fun [S] S
- Parameters
-
S : a reference
- Returns
- S : the appropriate string
| loc_gets | ( | ref | , |
| listParam | |||
| ) |
Return the translation of a given reference. If the reference is not found, the "unknown string" (see below) is returned.
- See Also
- loc_setUnknown
- loc_getUnknown
Prototype: fun [S [S r1]] S
- Parameters
-
S : a reference [S r1] : a list of strings to replace parameters (in the same order)
- Returns
- S : the appropriate string
| 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.
- See Also
- loc_setUnknown
- loc_initEx
Prototype: fun [S] I
- Parameters
-
S : a base pathname (like "tutorials/lang/mylocapp") i.e. without language name nor extension (see above)
- Returns
- I : 0 if success, nil if error.
| 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.
- See Also
- loc_setLangDefault
Prototype: fun [S S] I
- Parameters
-
S : a base pathname (like "tutorials/lang/mylocapp") i.e. without language name nor extension (see above) S : the language
- Returns
- I : 0 if success, nil if error.
| loc_clear | ( | ) |
Clear the current localisation. It should be used before to reload a language file.
- See Also
- loc_init
- loc_initEx
Prototype: fun [] I
- Returns
- I : always 0.
| loc_setUnknown | ( | str | ) |
Set the returned string when no reference is found. By default, it is "*".
Prototype: fun [S] S
- Parameters
-
S : a string
- Returns
- S : the same string.
| loc_getUnknown | ( | ) |
Get the returned string when no reference is found. By default, it is "*".
Prototype: fun [] S
- Returns
- S : this string.
| 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.
The default language is used when other langauage files are unknown or invalid. Thus, the default language file should always exist.
<b>Prototype:</b> fun [S] S
- Parameters
-
S : a default language
- Returns
- S : the same string or nil if error (loc_init alreday called or the string is nil).
| loc_getDefaultLang | ( | ) |
Get the default language. By default, it is "english".
Prototype: fun [] S
- Returns
- S : this string.
| loc_getLang | ( | ) |
Get the language used by this client.
Prototype: fun [] S
- Returns
- S : this language.
| loc_getDefaultParamSymbol | ( | ) |
Return the default symbol for parameters.
By default, it is "##". *
Prototype: fun [] S
- Returns
- S : this symbol.
| loc_setDefaultParamSymbol | ( | str | ) |
Set the default symbol for parameters. The language file should not be loaded yet. * By default, it is "##".
Prototype: fun [S] S
- Returns
- S : the same string or nil if an error occurs.
| loc_isLoaded | ( | ) |
Return if a language is currently loaded.
Prototype: fun [] I
- Returns
- I : 1 : loaded, 0 : not loaded
Generated on Sat Jan 31 2015 19:15:44 for Scol standard library package by
1.8.1.2

