i74ifa/locale

1.1 2021-11-08 10:20 UTC

This package is auto-updated.

Last update: 2024-11-29 06:41:34 UTC


README

simple package for Languages Support in your website

how to use:

lang/ar.php

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

lang/en.php

<?php
return [
    
]

index.php

<?php
// setup
require __dir__ . '/vendor/autoload.php';

use I74ifa/Locale/Locale;

// directory to languages

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

and simple use:

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

Suggest

Format

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

make function to help you

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



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

get locale

Locale::locale() // output ar

Example

Change ltr or rtl

<html>
    <head></head>
    <body dir="<?= Locale::locale() == 'ar' ? 'rtl' : 'ltr' ?>">
    
    <!--Here is your Amazing code-->
    
    </body>
    
</html>

Licence

MIT license.