class Translator

Class Translator Handles loading and translating language strings from various sources.

Properties

static array $translations

Methods

static 
init()

Initializes the translations by loading locale files from modules and the project folder.

static 
locales_recursive(string $path)

Recursively loads locale files from a given path.

static bool
addPath(string $path)

Adds a new translation path to the list.

static string
translate(string $string, array $placeholders = [])

Translates a string using loaded translations and replaces placeholders.

static 
refresh()

Refreshes the translations by re-initializing them.

Details

at line 20
static init()

Initializes the translations by loading locale files from modules and the project folder.

at line 33
static locales_recursive(string $path)

Recursively loads locale files from a given path.

Parameters

string $path

The directory or file path to search for locale files.

at line 63
static bool addPath(string $path)

Adds a new translation path to the list.

Parameters

string $path

The file path to add.

Return Value

bool

True if added, false otherwise.

at line 85
static string translate(string $string, array $placeholders = [])

Translates a string using loaded translations and replaces placeholders.

Parameters

string $string

The string to translate.

array $placeholders

Key-value pairs for placeholder replacement.

Return Value

string

The translated string.

at line 94
static refresh()

Refreshes the translations by re-initializing them.