Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Latest commit

 

History

History
108 lines (88 loc) · 8.17 KB

cp.i18n.localeID.md

File metadata and controls

108 lines (88 loc) · 8.17 KB

docs » cp.i18n.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
  • is
  • parse
  • Constructors - API calls which return an object, typically one that offers API methods
  • forCode
  • Fields - Variables which can only be accessed from an object returned by a constructor
  • code
  • language
  • localName
  • name
  • region
  • script
  • Methods - API calls which can only be made on an object returned by a constructor
  • matches

API Documentation

Functions

Signature cp.i18n.localeID.is(other) -> boolean
Type Function
Description Checks if the other is a localeID.
Parameters
  • other - the other value to check.
Returns
  • true if it is a cp.i18n.locale, otherwise false.
Signature cp.i18n.localeID.parse(code) -> string, string, string
Type Function
Description Parses a language ID into three possible string components:
Parameters
  • code - The locale 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

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
  • code - The language ID code.
Returns
  • The matching langaugeID, or nil.

Fields

Signature cp.i18n.localeID.code <string>
Type Field
Description The locale ID code.
Signature cp.i18n.localeID.language <cp.i18n.language>
Type Field
Description The matching language details.
Signature cp.i18n.localeID.localName <string>
Type Field
Description The local name in it's own language.
Signature cp.i18n.localeID.name <string>
Type Field
Description The locale name in English.
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.
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

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
  • otherLocale - The other locale to compare to.
Returns
  • A number from 0 to 3 indicating the match strength.