PHP code example of felicity-php / felicity-translate
1. Go to this page and download the library: Download felicity-php/felicity-translate 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/ */
felicity-php / felicity-translate example snippets
use felicity\config\Config;
use felicity\translate\Translate;
Config::set('lang.defaultLocale', 'en');
Config::set('lang.locale', 'de');
Config::set('lang.translations.en.myCategory', [
'myTranslationKey' => 'Translation of something',
'anotherTranslationKey' => 'Translation of something with {{var}}',
]);
Config::set('lang.translations.de.myCategory', [
'myTranslationKey' => 'Übersetzung von etwas',
'anotherTranslationKey' => 'Übersetzung von etwas mit {{var}}',
]);
$myTranslation = Translate::get('myCategory', 'myTranslationKey');
$anotherTranslation = Translate::get('myCategory', 'anotherTranslationKey', [
'{{var}}' => 'someVal',
]);
use felicity\config\Config;
Config::set('lang.defaultTwigCategory', 'myCategory');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.