localeID

As per Apple's documentation, a local ID is a code which identifies either a language used across multiple regions, a dialect from a specific region, a script used in multiple regions, or a combination of all three. 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 any specified 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.localeID.is(other) -> boolean

Type

Function

Description

Checks if the other is a localeID.

Parameters

Returns

parse

Signature

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

Type

Function

Description

Parses a language ID into three possible string components:

Parameters

Returns

Constructors

forCode

Signature

cp.i18n.localeID.forCode(code) -> cp.i18n.localeID or nil

Type

Constructor

Description

Creates, or retrieves from the cache, a localeID instance for the specified code.

Parameters

Returns

Fields

code

Signature

cp.i18n.localeID.code <string>

Type

Field

Description

The locale ID code.

language

Signature

cp.i18n.localeID.language <cp.i18n.language>

Type

Field

Description

The matching language details.

localName

Signature

cp.i18n.localeID.localName <string>

Type

Field

Description

The local name in it's own language.

name

Signature

cp.i18n.localeID.name <string>

Type

Field

Description

The locale name in English.

region

Signature

cp.i18n.localeID.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.localeID.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

matches

Signature

cp.i18n.localeID:matches(otherLocale) -> number

Type

Method

Description

This compares the otherLocale to this locale and returns a number indicating the 'strength'

Parameters

Returns