Internationalisation
Bundled Plugins API
languageID
As per Apple's documentation, a language ID is a code which identifies either a language used across multiple regions, a dialect from a specific region, or a script used in multiple regions. See the parse function for details.
When you parse a code with the forCode function, it will result in a table that contains a reference to the approprate cp.i18n.language table, and up to one of either the matching cp.i18n.region or cp.i18n.script tables. These contain the full details for each language/regin/script, as appropriate.
You can also convert the resulting table back to the code via tostring, or the code method.

API Overview

  • Functions - API calls offered directly by the extension
  • is
  • parse
  • Constructors - API calls which return an object, typically one that offers API methods
  • forCode
  • forParts
  • Fields - Variables which can only be accessed from an object returned by a constructor
  • code
  • language
  • region
  • script
  • Methods - API calls which can only be made on an object returned by a constructor

API Documentation

Functions

is

Signature
cp.i18n.languageID.is(thing) -> boolean
Type
Function
Description
Checks if the thing is a languageID instance.
Parameters
  • thing - the thing to check.
Returns
  • true if the thing is a languageID, otherwise false.

parse

Signature
cp.i18n.languageID.parse(code) -> string, string, string
Type
Function
Description
Parses a language ID into three possible string components:
Parameters
  • code - The language ID code. Eg. "en-AU".
Returns
  • language - The two-character lower-case alpha language code.
  • script - the four-character mixed-case alpha script code.
  • region - The two-character upper-case alpha region code.

Constructors

forCode

Signature
cp.i18n.languageID.forCode(code) -> cp.i18n.languageID, string
Type
Constructor
Description
Creates, or retrieves from the cache, a languageID instance for the specified code.
Parameters
  • code - The language ID code.
Returns
  • The matching languageID, or nil if the language ID couldn't be found.
  • The error message, or nil if there was no problem.
Signature
cp.i18n.languageID.forLocaleID(code[, prioritiseScript]) -> cp.i18n.languageID, string
Type
Constructor
Description
Creates, or retrieves from the cache, a languageID instance for the specified cp.i18n.localeID.
Parameters
  • locale - The localeID to convert
  • prioritiseScript - If set to true and the locale has both a region and script then the script code will be used.
Returns
  • The languageID for the locale, or nil
  • The error message if there was a problem.

forParts

Signature
cp.i18n.languageID.forParts(languageCode[, scriptCode[, regionCode]]) -> cp.i18n.languageID
Type
Constructor
Description
Returns a languageID with the specified parts.
Parameters
  • languageCode - Language code
  • scriptCode - Optional Script code
  • regionCode - Optional Region Code
Returns
  • A cp.i18n.languageID object.

Fields

code

Signature
cp.i18n.languageID.code <string>
Type
Field
Description
The language ID code.

language

Signature
cp.i18n.languageID.language <cp.i18n.language>
Type
Field
Description
The matching language details.

region

Signature
cp.i18n.languageID.region <cp.i18n.region>
Type
Field
Description
The matching region details, if appropriate. Will be nil if no region was specified in the code.

script

Signature
cp.i18n.languageID.script <cp.i18n.script>
Type
Field
Description
The matching script details, if appropriate. Will be nil if no script was specified in the code.

Methods

Signature
cp.i18n.languageID:toLocaleID() -> cp.i18n.localeID
Type
Method
Description
Returns the cp.i18n.localeID equivalent for this languageID.
Parameters
  • None
Returns
  • The matching localeID.
Last modified 1mo ago