1. Go to this page and download the library: Download jdz/language 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/ */
jdz / language example snippets
use JDZ\Language\Language;
$language = new Language(
// app languages
['fr', 'en'],
// default language
'fr'
);
$welcomeMessage = $language->get('welcome_message');
// Hi !
$customMessage = $language->get('custom.key');
// My custom value
$notDefined = $language->get('test.me');
// test.me (returns key if not found)
$notDefinedButDefault = $language->get('test.me', [], 'Default value');
// Default value
use JDZ\Language\LanguageCode;
// Check if a language code is valid
if (LanguageCode::isValid('fr')) {
// Valid language
}
// Get language from enum
$french = LanguageCode::FRENCH;
echo $french->value; // 'fr'
// Try to get enum from string
$lang = LanguageCode::tryFrom('en'); // Returns LanguageCode::ENGLISH or null
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.