LanguagePresets
in package
Infrastructure class for predefined language definitions.
Provides access to default language configurations including ISO codes, regex patterns, and display settings.
Tags
Table of Contents
Properties
- $definitions : array<string, array{0: string, 1: string, 2: bool, 3: string, 4: string, 5: bool, 6: bool, 7: bool}>|null
- Cached language definitions.
- $jsonPath : string
- Path to JSON definitions file.
Methods
- clearCache() : void
- Clear cached definitions (for testing).
- exists() : bool
- Check if a language is defined.
- get() : array{0: string, 1: string, 2: bool, 3: string, 4: string, 5: bool, 6: bool, 7: bool}|null
- Get definition for a specific language.
- getAll() : array<string, array{0: string, 1: string, 2: bool, 3: string, 4: string, 5: bool, 6: bool, 7: bool}>
- Get all language definitions in legacy array format.
- getGlosbeIso() : string|null
- Get Glosbe ISO code for a language.
- getGoogleIso() : string|null
- Get Google ISO code for a language.
- getNames() : array<string|int, string>
- Get all language names.
- isRightToLeft() : bool
- Check if a language uses right-to-left script.
- usesBiggerFont() : bool
- Check if a language requires bigger font.
- loadFromJson() : array<string, array{0: string, 1: string, 2: bool, 3: string, 4: string, 5: bool, 6: bool, 7: bool}>
- Load language definitions from JSON file.
Properties
$definitions
Cached language definitions.
private
static array<string, array{0: string, 1: string, 2: bool, 3: string, 4: string, 5: bool, 6: bool, 7: bool}>|null
$definitions
= null
$jsonPath
Path to JSON definitions file.
private
static string
$jsonPath
= __DIR__ . '/Data/langdefs.json'
Methods
clearCache()
Clear cached definitions (for testing).
public
static clearCache() : void
exists()
Check if a language is defined.
public
static exists(string $name) : bool
Parameters
- $name : string
-
Language name
Return values
boolget()
Get definition for a specific language.
public
static get(string $name) : array{0: string, 1: string, 2: bool, 3: string, 4: string, 5: bool, 6: bool, 7: bool}|null
Parameters
- $name : string
-
Language name (e.g., "English", "Japanese")
Return values
array{0: string, 1: string, 2: bool, 3: string, 4: string, 5: bool, 6: bool, 7: bool}|nullgetAll()
Get all language definitions in legacy array format.
public
static getAll() : array<string, array{0: string, 1: string, 2: bool, 3: string, 4: string, 5: bool, 6: bool, 7: bool}>
Returns an associative array where keys are language names and values are indexed arrays with the following structure:
- 0: glosbeIso (string) - Glosbe dictionary ISO code
- 1: googleIso (string) - Google Translate ISO code
- 2: biggerFont (bool) - Whether to use larger font
- 3: wordCharRegExp (string) - Regex for word characters
- 4: sentSplRegExp (string) - Regex for sentence splitting
- 5: makeCharacterWord (bool) - Whether to split characters as words
- 6: removeSpaces (bool) - Whether to remove spaces
- 7: rightToLeft (bool) - Whether language is RTL
Tags
Return values
array<string, array{0: string, 1: string, 2: bool, 3: string, 4: string, 5: bool, 6: bool, 7: bool}>getGlosbeIso()
Get Glosbe ISO code for a language.
public
static getGlosbeIso(string $name) : string|null
Parameters
- $name : string
-
Language name
Return values
string|null —Glosbe ISO code or null if not found
getGoogleIso()
Get Google ISO code for a language.
public
static getGoogleIso(string $name) : string|null
Parameters
- $name : string
-
Language name
Return values
string|null —Google ISO code or null if not found
getNames()
Get all language names.
public
static getNames() : array<string|int, string>
Return values
array<string|int, string>isRightToLeft()
Check if a language uses right-to-left script.
public
static isRightToLeft(string $name) : bool
Parameters
- $name : string
-
Language name
Return values
boolusesBiggerFont()
Check if a language requires bigger font.
public
static usesBiggerFont(string $name) : bool
Parameters
- $name : string
-
Language name
Return values
boolloadFromJson()
Load language definitions from JSON file.
private
static loadFromJson() : array<string, array{0: string, 1: string, 2: bool, 3: string, 4: string, 5: bool, 6: bool, 7: bool}>