PHP code example of rnr1721 / multilingual-core

1. Go to this page and download the library: Download rnr1721/multilingual-core 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/ */

    

rnr1721 / multilingual-core example snippets



// Create language instances
$languages = [
    new Language('en', 'English', 'en_US'),
    new Language('ru', 'Russian', 'ru_RU', false)
];

// Implement LocaleManagerInterface for your framework
class MyFrameworkLocaleManager implements LocaleManagerInterface 
{
    public function setLocale(string $locale): void 
    {
        // Framework-specific locale setting
    }
}

// Create language manager
$manager = new LanguageManager(
    new MyFrameworkLocaleManager(),
    $languages,
    'en' // default language
);

// Language switching example
$manager->setCurrentLanguage('ru'); // Will also set framework locale to ru_RU