PHP code example of i74ifa / locale

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

    

i74ifa / locale example snippets



return [
    'welcome' => 'مرحبا',
    'have a nice day' => 'اتمنى لك يوم جميل'
];


return [
    
]


// setup
cale/Locale;

// directory to languages

$dir = __DIR__ . '/lang';
Locale::set('ar', $dir);

Locale::get('welcome') // output مرحبا
 

<h1><?= Locale::get('Hello') 

function __($filed) {
    return Locale::get($filed);
}



<h1><?= __('Hello') 

Locale::locale() // output ar

<html>
    <head></head>
    <body dir="<?= Locale::locale() == 'ar' ? 'rtl' : 'ltr'