Posted 12 October 2013 - 06:16 PM
ComputerCraft, at the moment, lacks a system for creating localized strings. This API intends to solve that. This can be used as an API, from the shell, and with language files.
API Usage
Shell Usage:
Any of the API functions can be called through the shell. Simply use:
Language Files:
The default path for language files is just /lang. To add directories to search in, append :(your path). So lang:mylang:rom/lang would be valid, although nothing would come from rom/lang. Any files in the path define localizations. The file name represents the language the file defines. File names with a .lang extension will have the .lang omitted. Here's an example language file
For those of you who care, here's the pattern used for matching rules in language files.
pastebin get JFJAdfkL language
API Usage
Spoiler
setString(language, key, value)
For the given language, set the string for the key
removeString(language, key)
For the given language, remove the string for the key
removeStringForAll(key)
For all languages, remove the string for the key
getString(key)
For the current language, get the string for the key
setPath(sPath)
Set the path list in which language files are searched for
getPath()
Get the path list in which language files are searched for
getCurrentLanguage()
Get the current language
setCurrentLanguage(sLanguage)
Set the current language
reloadLanguageFiles()
Reload language files from path
Shell Usage:
Any of the API functions can be called through the shell. Simply use:
localize (function) [arguments]
Language Files:
The default path for language files is just /lang. To add directories to search in, append :(your path). So lang:mylang:rom/lang would be valid, although nothing would come from rom/lang. Any files in the path define localizations. The file name represents the language the file defines. File names with a .lang extension will have the .lang omitted. Here's an example language file
some.key = some string
some.key2 = another string
For those of you who care, here's the pattern used for matching rules in language files.
([^%s=]+)%s*=%s*([^\n]+)\n?
pastebin get JFJAdfkL language