i18n library

Typelibrary
Dictionarylibrary.i18n
Libraryi18n library
Associationscom.livecode.library.i18n
Summary

It consists of a translation system that allows support for multiple languages in our LiveCode applications.

Description

In order for the bookstore to understand your language packs or translations, they must follow some rules. The first three cannot be empty. - id*: It is a text string for the language ID in the application, so it will have to be unique. Examples of possible id are:en-US, es-ES. This key is required - name: Which will be a text string to be used as the name of the language, if you don't pass this value when requesting the name of the language pack, the ID will be returned if the name is empty. Examples of possible names are:English (United States), Spanish. - values*: An array in which the translations are stored in a key value format. Where each key represents a translation and its value corresponds to the text in that language. The name of the keys cannot vary from one language to another. As if the values associated with them were going to change. Pluralization is also handled within values._This key is required_ - contexts: It is an ordered array, where each key has matches and values within the keys. The value key has the same structure and function as the one at the root. Whereas the matches key will have a key value.

An example of a language pack would be the following, it is in JSON format. { "id": "en", "values": { "Yes": "Yes", "No": "No" }, "contexts": [ { "matches": { "gender": "male" }, "values": { "%{name} updated their profile": "%{name} updated his profile" } }, { "matches": { "gender": "female" }, "values": { "%{name} updated their profile": "%{name} updated her profile" } } ], "name": "English" } or { "en": { "id": "en", "values": { "homepage.title": "Hello, World!", "homepage.welcome": "Hi <b>strong</b>%{name}<b>/strong</b>, how are you?", "homepage.time": "The current time is: %{time}" } }, "es": { "id": "es", "values": { "homepage.title": "åÁHola Mundo!", "homepage.welcome": "Hola, <b>strong</b>%{name}<b>/strong</b>, åÀcÌ?mo estÌÁs?", "homepage.time": "La hora actual es: %{time}" } } }

For more information, go to the Guide section and read "Simple i18n for LiveCode Applications".

TypeNameSummarySyntax
commandcleanupLocalesStorage

Remove all i18n packages from storage

cleanupLocalesStorage

- - -exportLocaleToFile

Exports the array of an i18n package loaded in memory to a file.

exportLocaleToFile <pLocaleID>, <pFilePath>

- - -i18nInit

Initialize internationalization packages

i18nInit <pLocaleToLoad>, [<pLocaleByDefault>]

- - -loadLocale

Load one or more i18n packages.

loadLocale <pLangPackArray>, [<pAutoStartup>]

- - -loadLocaleFromFile

Load one or more i18n packages from a file.

loadLocaleFromFile <pURL>, [<pAutoStartup>]

- - -setActiveLocale

Sets the i18n package, which is used to do all translation operations.

setActiveLocale <pLocaleID>

- - -unloadLocale

Remove a package from i18n.

unloadLocale <pLocaleID>

- - -updateLocale

Updates object properties based on the current language pack or any other previously loaded.

updateLocale <pLongId>, [<pLocaleID>]

functiongetActiveLocale

Gets the ID of the current i18n bundle.

getActiveLocale()

- - -getActiveLocaleName

Gets the name of the current i18n bundle.

getActiveLocaleName()

- - -loadedLocaleIDs

Get the ids of the i18n packages found in the i18n storage.

loadedLocaleIDs()

- - -loadedLocaleNames

Get the names of the i18n packages found in the i18n storage.

loadedLocaleNames()

- - -translate

get a text string from the i18n package.

translate <pStringID>, [<pPluralisation>], [<pFormattingArray>], [<pContextArray>], [<pDefaultText>], [<pLocaleID>]

libraryi18n library

It consists of a translation system that allows support for multiple languages in our LiveCode applications.

translate <pStringID>, [<pPluralisation>], [<pFormattingArray>], [<pContextArray>], [<pDefaultText>], [<pLocaleID>]

messagelocaleChanged

This message is sent when the user changes the current language.

localeChanged <pNewLocaleID>, <pOldLocaleID>

propertyi18n

Use this property to get and set the internationalization of objects.

set the i18n[propertyName] of object to "Translation_Tag"

get the i18n[propertyName] of object