PHP code example of modera / translations-bundle

1. Go to this page and download the library: Download modera/translations-bundle 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/ */

    

modera / translations-bundle example snippets

 php

// config/bundles.php

return [
    // ...
    Modera\LanguagesBundle\ModeraLanguagesBundle::class => ['all' => true], // if you still don't have it
    Modera\TranslationsBundle\ModeraTranslationsBundle::class => ['all' => true],
];
 xml
<!-- YourBundleName/Resources/config/services.xml -->
<services>
    <service parent="modera_translations.handling.template_translation_handler">

        <argument>YourBundleName</argument>

        <tag name="modera_translations.translation_handler" />
    </service>
</services>
 xml
<!-- YourBundleName/Resources/config/services.xml -->
<services>
    <service parent="modera_translations.handling.php_classes_translation_handler">

        <argument>YourBundleName</argument>

        <tag name="modera_translations.translation_handler" />
    </service>
</services>
 php


use Modera\TranslationsBundle\Helper\T;

T::trans('Hello');

T::trans('Hello, %name%', array('%name%' => $name'), 'greetings');

$domain = 'examples';
$longMessage = 'This way of defining long translation ';
$longMessage.= 'messages can be used.';
$longMessage.= 'For more details please see docblock for T class.';

T::trans($longMessage, array(), $domain);