Lang
in package
Internationalization and Localization Class
This class provides a simple translation system with two main functions:
- set: to define a string and its translation
- get: to retrieve the translation for a string
The class supports area-specific translations, allowing different translations for the same string in different parts of the application.
Tags
Table of Contents
Methods
- get() : string
- Gets the translation for a string
- load_ini_file() : bool
- Upload a translation file
- set() : void
- Sets a string and its translation
Methods
get()
Gets the translation for a string
public
static get(string $string[, string $area = 'all' ]) : string
This method retrieves the translation for a specific string in the specified area. If no translation is found in the specified area, it falls back to the 'all' area. If no translation is found at all, it returns the original string.
Parameters
- $string : string
-
The original string to translate
- $area : string = 'all'
-
The area to look for the translation in (default: 'all')
Tags
Return values
string —The translated string or the original if no translation is found
load_ini_file()
Upload a translation file
public
static load_ini_file(string $file[, string $area = 'all' ]) : bool
Parameters
- $file : string
- $area : string = 'all'
Return values
boolset()
Sets a string and its translation
public
static set(string $string, string $translation[, string $area = 'all' ]) : void
This method defines a translation for a specific string. Translations can be limited to specific areas of the application by specifying the area parameter.
Parameters
- $string : string
-
The original string to translate
- $translation : string
-
The translated string
- $area : string = 'all'
-
The area to limit this translation to (default: 'all')