languageID

Last updated 4 months ago

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

  • Constructors - API calls which return an object, typically one that offers API methods

  • Fields - Variables which can only be accessed from an object returned by a constructor

  • 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

Returns

parse

Signature

cp.i18n.languageID.parse(code) -> string, string, string

Type

Function

Description

Parses a language ID into three possible string components:

Parameters

Returns

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

Returns

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

Returns

forParts

Signature

cp.i18n.languageID.forParts(languageCode[, scriptCode[, regionCode]]) -> cp.i18n.languageID

Type

Constructor

Description

Returns a languageID with the specified parts.

Parameters

Returns

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

Returns