Jeedom Core

translate
in package

Handles internationalization (i18n) for Jeedom system

Provides translation capabilities for both core system and plugins, with caching mechanisms for better performance.

Tags
see
config

For language configuration

see
plugin

For plugin-related translations

Table of Contents

Properties

$language  : string|null
$translation  : array<string, array<string, array<string, string>>>
$config  : array<string, string>|null
$pluginLoad  : array<string, bool>
$widgetLoad  : array<string, array<string, array<string, string>>>

Methods

exec()  : string
Processes text content for internationalization
getConfig()  : string
Retrieves a configuration value
getLanguage()  : string
Gets current active language
getPathTranslationFile()  : string
Returns path to language translation file
getPluginFromName()  : string
Extracts plugin name from file path
getTranslation()  : array<string, array<string, string>>
Gets translations for a plugin
getWidgetPathTranslationFile()  : string
Returns path to widget translation file
getWidgetTranslation()  : array<string, array<string, string>>
Gets translations for a widget
loadTranslation()  : array<string, array<string, string>>
Loads translations for core or plugin
sentence()  : string
Translates a single text key
setLanguage()  : void
Sets active language

Properties

$language

protected static string|null $language = \null

Current active language

$translation

protected static array<string, array<string, array<string, string>>> $translation = array()

Cached translations by language and namespace

$config

private static array<string, string>|null $config = \null

System configuration cache

$pluginLoad

private static array<string, bool> $pluginLoad = array()

Loaded plugins tracking

$widgetLoad

private static array<string, array<string, array<string, string>>> $widgetLoad = array()

Loaded widgets translations

Methods

exec()

Processes text content for internationalization

public static exec(string $_content[, string $_name = '' ][, bool $_backslash = false ]) : string
Parameters
$_content : string

Text with {{translation_keys}}

$_name : string = ''

Plugin/widget identifier or path

$_backslash : bool = false

Whether to escape single quotes

Tags
see
self::getLanguage()

For current language

see
self::getTranslation()

For plugin translations

see
self::getWidgetTranslation()

For widget translations

Return values
string

Translated content

getConfig()

Retrieves a configuration value

public static getConfig(string $_key[, string $_default = '' ]) : string
Parameters
$_key : string

Configuration key to retrieve

$_default : string = ''

Default value if key not found

Tags
see
config::byKeys()

For configuration retrieval

Return values
string

Configuration value

getLanguage()

Gets current active language

public static getLanguage() : string
Return values
string

Language code

getPathTranslationFile()

Returns path to language translation file

public static getPathTranslationFile(string $_language) : string
Parameters
$_language : string

Language code

Return values
string

File path

getPluginFromName()

Extracts plugin name from file path

public static getPluginFromName(string $_name) : string
Parameters
$_name : string

File path

Return values
string

Plugin name or 'core'

getTranslation()

Gets translations for a plugin

public static getTranslation(string $_plugin) : array<string, array<string, string>>
Parameters
$_plugin : string

Plugin identifier

Return values
array<string, array<string, string>>

Translation mappings

getWidgetPathTranslationFile()

Returns path to widget translation file

public static getWidgetPathTranslationFile(string $_widgetName) : string
Parameters
$_widgetName : string

Widget name

Return values
string

File path

getWidgetTranslation()

Gets translations for a widget

public static getWidgetTranslation(string $_widget) : array<string, array<string, string>>
Parameters
$_widget : string

Widget identifier

Return values
array<string, array<string, string>>

Translation mappings

loadTranslation()

Loads translations for core or plugin

public static loadTranslation([string|null $_plugin = null ]) : array<string, array<string, string>>
Parameters
$_plugin : string|null = null

Plugin name or null for core

Tags
see
plugin::getTranslation()

For plugin translations

Return values
array<string, array<string, string>>

Translation mappings

sentence()

Translates a single text key

public static sentence(string $_content, string $_name[, bool $_backslash = false ]) : string
Parameters
$_content : string

Translation key

$_name : string

Plugin/widget identifier or path

$_backslash : bool = false

Whether to escape single quotes

Tags
see
self::exec()

For full translation processing

Return values
string

Translated text

setLanguage()

Sets active language

public static setLanguage(string $_langage) : void
Parameters
$_langage : string

Language code


        
On this page

Search results