locale_info := OneLocale_Init(optional_args := "")
Detects the user’s language, loads the best-matching .lang file (or baked map), and prepares everything for sT().
Accepts an object containing named values. See the table below.
Returns an object with various named values. Check .success first — if false, show .errmsg and abort.
locale_info := OneLocale_Init()
if !locale_info.success {
MsgBox locale_info.errmsg, , "Icon!"
ExitApp
}
optional_args (all others keep sensible defaults)| Key | Default | Meaning |
|---|---|---|
sLangFolder |
“lang” | Where your .lang files live |
sName |
Script name | Base name for ini/lang files |
noLangFile |
false | Use the .ini itself as the language file |
sFallback |
“en” | Language to use when nothing else matches |
mapPriority |
true | Baked maps win over loose .lang files |
{Object} optional_args - a set of named values, listed below.
You only need to supply the values which are non-default.
noLangFile {Boolean} default = false
sLangFolder is ignored;
on return, docsPath will be A_ScriptDir “" sName “.” sDocExt;
its existence is NOT tested for.sLangFolder {String} default = “lang”
sLangFolder is “” (empty), .LANG files go in script directorysDocsFolder {String} default = “docs”
sDocsFolder is “” (empty), help files go in script directorysName {String} default = “”
sName is empty (default), it’s set to A_ScriptName without extensionsLangName {String} default = “”
A_ScriptName -[/TAG/];
this routine replaces /TAG/ with the active Language TagsDocName {String} default = “”
A_ScriptName -[/TAG/];
this routine replaces /TAG/ with the active Language TagsDocExt {String} default = “html”
sDocName is “MyScript-readme”, sDocExt is “txt” and the
language ID is “en”, this function looks for a file named “MyScript-readme-[en].txt”sFallback {String} default = “en”
.fallback will be true;
A_Language; in this case leave
the .INI entry blank; the closest available language will be chosen automatically.sLangID {String} default = “(auto)”
sLangID overrides any .INI file entry.sLangID argument, A_Language will be used for automatic
language selection (provided a compatible language file has been installed)sLangID sources, lowest to highest priotity:
A_Language, .INI file, optional_argssLangID (wherever it came from) isn’t a valid language ID, this routine fails.mapPriority {Boolean} default true; determines whether Maps (‘baked’ data) or .LANG Files have priority when a given Language is supported by both. Setting this to false means any .LANG files in sLangFolder will be preferred over any baked data, as long as they are compatible with the requested language.{Object} with the following properties:
.success {Boolean} if true, the initialization was successful.
.errmsg {String} error or warning message, if any.
.langID {String} ISO Tag or LCID code for the current language;
g_lang_id.name {String} human-readable language name (e.g., “English”)
.fallback {Boolean} if true, the Fallback language was used.
.iniPath {String} location of main .INI file
.success will be falseg_ini_path.langPath {String} location of active .LANG file
noLangFile argument was set, .langPath will be same as .iniPathg_lang_path.docsPath {String} location of active docs (help) file, if any;
noLangFile argument was set, .docsPath will be the empty stringg_docs_path.isoTag {String} ISO Tag for the current language.lcid {String} 4-hex-digit LCID code for the current language
.isoTag and .lcid are alternate ways of specifying a language..langMap {Boolean} if true, ‘baked’ (hard coded) language data was used;
,langMap is true, .langPath and g_lang_path will be “:map:”sLangFolder {String} copied from argumentsName {String} copied from argumentmapPriority {Boolean} copied from argumentBack to README