Scol standard library package  0.3.1
Common and usefull functions for all Scol applications
Functions
A localization API

Functions

 loc_clear ()
 Clear the current localisation. It should be used before to reload a language file. More...
 
 loc_get (ref)
 Return the translation of a given reference. If the reference is not found, the "unknown string" (see below) is returned. More...
 
 loc_getDefaultLang ()
 Get the default language. By default, it is "english". More...
 
 loc_getDefaultParamSymbol ()
 Return the default symbol for parameters. More...
 
 loc_getLang ()
 Get the language used by this client. More...
 
 loc_gets (ref, listParam)
 Return the translation of a given reference. If the reference is not found, the "unknown string" (see below) is returned. More...
 
 loc_getUnknown ()
 Get the returned string when no reference is found. By default, it is "*". More...
 
 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. More...
 
 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. More...
 
 loc_isLoaded ()
 Return if a language is currently loaded. More...
 
 loc_setDefaultParamSymbol (str)
 Set the default symbol for parameters. The language file should not be loaded yet. * By default, it is "##". More...
 
 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. More...
 
 loc_setUnknown (str)
 Set the returned string when no reference is found. By default, it is "*". More...
 

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.

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
[Sr1] : 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.

Prototype: 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