PHP code example of locomotivemtl / charcoal-translation
1. Go to this page and download the library: Download locomotivemtl/charcoal-translation 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/ */
locomotivemtl / charcoal-translation example snippets
use \Charcoal\Translation\TranslationConfig;
$translation_config = TranslationConfig::instance();
// Set the list of available languages
$translation_config->set_available_langs([
'en' => [],
'fr' => []
]);
// Set the default language to "English" ("en")
$translation_config->set_default_lang('en');
// Set the current language to French
$translation_config->set_lang('fr');
// Let's assume the default language has been set to 'en'...
use \Charcoal\Translation\TranslationString;
$str = new TranslationString([
'fr' => 'foo',
'en' => 'bar'
]);
// All the following examples output "bar"
echo $str;
echo $str->en();
echo $str->val('en');
// All the following examples output "foo"
echo $str->fr();
echo $str->set_lang('fr')->val();
echo $str->val('fr');
//
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.