Documentation

Mage_Core_Model_Translate
in package

Maho

Tags
copyright

Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)

copyright

Copyright (c) 2019-2025 The OpenMage Contributors (https://openmage.org)

copyright

Copyright (c) 2024-2025 Maho (https://mahocommerce.com)

license

https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)

Table of Contents

Constants

CACHE_TAG  = 'translate'
CONFIG_KEY_AREA  = 'area'
CONFIG_KEY_DESIGN_PACKAGE  = 'package'
CONFIG_KEY_DESIGN_THEME  = 'theme'
CONFIG_KEY_LOCALE  = 'locale'
CONFIG_KEY_STORE  = 'store'
CSV_SEPARATOR  = ','
DEFAULT_STRING  = 'Translate String'
Default translation string
SCOPE_SEPARATOR  = '::'

Properties

$_cacheId  : string|null
Cache identifier
$_canUseInline  : bool
Configuration flag to local enable inline translations
$_config  : array<string|int, mixed>
Translator configuration array
$_data  : array<string|int, mixed>|null
Translation data
$_dataScope  : array<string|int, mixed>
Translation data for data scope (per module)
$_locale  : string|null
Locale name
$_translate  : Zend_Translate|null
Translation object
$_translateInline  : bool
Configuration flag to enable inline translations
$_useCache  : mixed

Methods

__construct()  : mixed
getCacheId()  : string
Retrieve cache identifier
getConfig()  : mixed
Retrieve config value by key
getData()  : array<string|int, mixed>
Retrieve translation data
getLocale()  : string
Retrieve locale
getModulesConfig()  : array<string|int, mixed>|SimpleXMLElement
Retrieve modules configuration by translation
getResource()  : Mage_Core_Model_Resource_Translate
Retrieve DB resource model
getTemplateFile()  : string
Retrieve translated template file
getTranslate()  : Zend_Translate
Retrieve translation object
getTranslateInline()  : bool
Retrieve active translate mode
init()  : $this
Initialization translation data
setConfig()  : $this
Initialize configuration
setLocale()  : $this
setTranslateInline()  : $this
Set Translate inline mode
translate()  : string
Translate
_addData()  : $this
Adding translation data
_canUseCache()  : false|array<string|int, mixed>
Check cache usage availability
_getFileData()  : array<string|int, mixed>
Retrieve data from file
_getModuleFilePath()  : string
Retrieve translation file for module
_getTranslatedString()  : string
Return translated string from text.
_loadCache()  : array<string|int, mixed>|false
Loading data cache
_loadDbTranslation()  : $this
Loading current store translation from DB
_loadModuleTranslation()  : $this
Loading data from module translation files
_loadThemeTranslation()  : $this
Loading current theme translation
_prepareDataString()  : string
_saveCache()  : $this
Saving data cache

Constants

CACHE_TAG

public mixed CACHE_TAG = 'translate'

CONFIG_KEY_AREA

public mixed CONFIG_KEY_AREA = 'area'

CONFIG_KEY_DESIGN_PACKAGE

public mixed CONFIG_KEY_DESIGN_PACKAGE = 'package'

CONFIG_KEY_DESIGN_THEME

public mixed CONFIG_KEY_DESIGN_THEME = 'theme'

CONFIG_KEY_LOCALE

public mixed CONFIG_KEY_LOCALE = 'locale'

CONFIG_KEY_STORE

public mixed CONFIG_KEY_STORE = 'store'

CSV_SEPARATOR

public mixed CSV_SEPARATOR = ','

DEFAULT_STRING

Default translation string

public mixed DEFAULT_STRING = 'Translate String'

SCOPE_SEPARATOR

public mixed SCOPE_SEPARATOR = '::'

Properties

$_cacheId

Cache identifier

protected string|null $_cacheId

$_canUseInline

Configuration flag to local enable inline translations

protected bool $_canUseInline = \true

$_config

Translator configuration array

protected array<string|int, mixed> $_config

$_data

Translation data

protected array<string|int, mixed>|null $_data = []

$_dataScope

Translation data for data scope (per module)

protected array<string|int, mixed> $_dataScope

$_locale

Locale name

protected string|null $_locale

$_translate

Translation object

protected Zend_Translate|null $_translate

$_translateInline

Configuration flag to enable inline translations

protected bool $_translateInline

$_useCache

protected mixed $_useCache = \true

Methods

getCacheId()

Retrieve cache identifier

public getCacheId() : string
Return values
string

getConfig()

Retrieve config value by key

public getConfig(string $key) : mixed
Parameters
$key : string

getData()

Retrieve translation data

public getData() : array<string|int, mixed>
Return values
array<string|int, mixed>

getLocale()

Retrieve locale

public getLocale() : string
Return values
string

getModulesConfig()

Retrieve modules configuration by translation

public getModulesConfig() : array<string|int, mixed>|SimpleXMLElement
Return values
array<string|int, mixed>|SimpleXMLElement

getTemplateFile()

Retrieve translated template file

public getTemplateFile(string $file, string $type[, string $localeCode = null ]) : string
Parameters
$file : string
$type : string
$localeCode : string = null
Return values
string

getTranslate()

Retrieve translation object

public getTranslate() : Zend_Translate
Return values
Zend_Translate

getTranslateInline()

Retrieve active translate mode

public getTranslateInline() : bool
Return values
bool

init()

Initialization translation data

public init(string $area[, bool $forceReload = false ]) : $this
Parameters
$area : string
$forceReload : bool = false
Return values
$this

setConfig()

Initialize configuration

public setConfig(array<string|int, mixed> $config) : $this
Parameters
$config : array<string|int, mixed>
Return values
$this

setLocale()

public setLocale(string $locale) : $this
Parameters
$locale : string
Return values
$this

setTranslateInline()

Set Translate inline mode

public setTranslateInline([bool $flag = null ]) : $this
Parameters
$flag : bool = null
Return values
$this

translate()

Translate

public translate(array<string|int, mixed> $args) : string
Parameters
$args : array<string|int, mixed>
Return values
string

_addData()

Adding translation data

protected _addData(array<string|int, mixed> $data, string $scope[, bool $forceReload = false ]) : $this
Parameters
$data : array<string|int, mixed>
$scope : string
$forceReload : bool = false
Return values
$this

_canUseCache()

Check cache usage availability

protected _canUseCache() : false|array<string|int, mixed>
Return values
false|array<string|int, mixed>

_getFileData()

Retrieve data from file

protected _getFileData(string $file) : array<string|int, mixed>
Parameters
$file : string
Return values
array<string|int, mixed>

_getModuleFilePath()

Retrieve translation file for module

protected _getModuleFilePath(string $module, string $fileName) : string
Parameters
$module : string
$fileName : string
Return values
string

_getTranslatedString()

Return translated string from text.

protected _getTranslatedString(string $text, string $code) : string
Parameters
$text : string
$code : string
Return values
string

_loadCache()

Loading data cache

protected _loadCache() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|false

_loadDbTranslation()

Loading current store translation from DB

protected _loadDbTranslation([bool $forceReload = false ]) : $this
Parameters
$forceReload : bool = false
Return values
$this

_loadModuleTranslation()

Loading data from module translation files

protected _loadModuleTranslation(string $moduleName, array<string|int, mixed> $files[, bool $forceReload = false ]) : $this
Parameters
$moduleName : string
$files : array<string|int, mixed>
$forceReload : bool = false
Return values
$this

_loadThemeTranslation()

Loading current theme translation

protected _loadThemeTranslation([bool $forceReload = false ]) : $this
Parameters
$forceReload : bool = false
Return values
$this

_prepareDataString()

protected _prepareDataString(string $string) : string
Parameters
$string : string
Return values
string

_saveCache()

Saving data cache

protected _saveCache() : $this
Return values
$this

        
On this page

Search results