PHP Classes

File: src/App/I18n/Translator.php

Recommend this page to a friend!
  Packages of Thierry Feuzeu   Jaxon   src/App/I18n/Translator.php   Download  
File: src/App/I18n/Translator.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Jaxon
Call PHP classes from JavaScript using AJAX
Author: By
Last change:
Date: 4 months ago
Size: 920 bytes
 

Contents

Class file image Download
<?php

namespace Jaxon\App\I18n;

/**
 * Translator.php
 *
 * A translator coupled with a config event listener.
 *
 * @package jaxon-core
 * @author Thierry Feuzeu <thierry.feuzeu@gmail.com>
 * @copyright 2022 Thierry Feuzeu <thierry.feuzeu@gmail.com>
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
 * @link https://github.com/jaxon-php/jaxon-core
 */

use Jaxon\App\Config\ConfigListenerInterface;
use
Jaxon\Config\Config;
use
Jaxon\Utils\Translation\Translator as BaseTranslator;

class
Translator extends BaseTranslator implements ConfigListenerInterface
{
   
/**
     * @inheritDoc
     */
   
public function onChange(Config $xConfig, string $sName): void
   
{
       
// Set the library language any time the config is changed.
       
if($sName === '' || $sName === 'core.language')
        {
           
$this->setLocale($xConfig->getOption('core.language'));
        }
    }
}