PHP code example of xanweb / c5-js-localization

1. Go to this page and download the library: Download xanweb/c5-js-localization library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xanweb / c5-js-localization example snippets


use Xanweb\C5\JsLocalization\Event\BackendAssetLocalizationLoad;

$this->app['director']->addListener(BackendAssetLocalizationLoad::NAME, function (BackendAssetLocalizationLoad $event) {
    $event->getAssetLocalization()->mergeWith([
        'i18n' => [
            'confirm' => t('Are you sure?'),
            'maxItemsExceeded' => t('Max items exceeded, you cannot add any more items.'),
            'pageNotFound' => t('Page not found'),
            'colorPicker' => [
                'cancelText' => t('Cancel'),
                'chooseText' => t('Choose'),
                'togglePaletteMoreText' => t('more'),
                'togglePaletteLessText' => t('less'),
                'noColorSelectedText' => t('No Color Selected'),
                'clearText' => t('Clear Color Selection'),
            ]
        ],
        'editor' => [
            'initRichTextEditor' => $this->app['editor']->getEditorInitJSFunction(),
        ],
    ]);
});

$view->

use Xanweb\C5\JsLocalization\Event\FrontendAssetLocalizationLoad;

$this->app['director']->addListener(FrontendAssetLocalizationLoad::NAME, function (FrontendAssetLocalizationLoad $event) {
    $event->getAssetLocalization()->mergeWith([
        'i18n' => [
            'message' => t('Are you sure?'),
        ],
        'methods' => [
            'showMessage' => 'function(){ alert("Website: ' . Core::make('site')->getSite()->getSiteName() . '"); }',
        ],
    ]);
});

$view->