PHP code example of ryanj93 / php-locale-kit

1. Go to this page and download the library: Download ryanj93/php-locale-kit 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/ */

    

ryanj93 / php-locale-kit example snippets


$package = new Package();
//path, locale, strict mode
//$locale is a string containing the locale code selected, if different by the given code, it means that a fallback locale has been picked.
$locale = $package->setPackage('path/to/the/package.db', 'en-US', false);

//Get all locales.
$locales = $package->getSupportedLocales();
//Check for a specific locale support.
//locale, strict mode
$value = $package->isLocaleSupported('en-US', false);

$labels = $package->getLabels(array(1, 2, 3));

$labels = $package->getAllLabels();

$translator = new Translator();
//token, text format
$translator->setupYandex('YOUR API TOKEN HERE', Translator::HTML);

//text, target language, original language
$texts = $translator->translateText(array('Ciao mondo!'), 'en', 'it');

//text, target language, original language
$detections = $translator->detectLanguage(array('Ciao mondo!'));

$languages = $translator->getSupportedLanguages('en');

//Setup cached for the package.
$package->setCache(true)->setCacheHandler($cache);
//Setup cached for the translator.
$translator->setCache(true)->setCacheHandler($cache);
`bash
composer