PHPackages                             ikevinshah/i18n - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. ikevinshah/i18n

AbandonedArchivedLibrary[Localization &amp; i18n](/categories/localization)

ikevinshah/i18n
===============

Simplistic i18n Class

1.0.1(6y ago)06MITPHPPHP ^7.0

Since Feb 26Pushed 6y ago1 watchersCompare

[ Source](https://github.com/iKevinShah/i18n)[ Packagist](https://packagist.org/packages/ikevinshah/i18n)[ Docs](https://www.ikevinshah.com)[ RSS](/packages/ikevinshah-i18n/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (3)Used By (0)

Simple i18n
===========

[](#simple-i18n)

A simplistic PHP Internationalization and localization class.

The class helps achieve internationalization (i18n) via separate ini files for separate languages.

### Installation

[](#installation)

Installation via composer

```
composer require ikevinshah/i18n

```

Installation without composer

1. Download the class file (src/i18n.php).
2. Include it in your code

```
require_once '/path/to/i18n.php';
```

Usage
-----

[](#usage)

1. Install using either `composer` or `including` the class
2. Set the variables as per your app, initialize and use `L::word` to display.

```
$i18n = new iKevinShah\i18n($language,$ini_directory,$cache_directory,$fallback_language);
$i18n->init();
```

**Note:** Ensure that `$language.ini` file exists in the `$ini_directory`. So example if I want to use russian (ru) on the current page and the `$ini_directory` is `/var/www/lang/`, class will search for ini file at the location of `/var/www/lang/ru.ini`. If the language file (ru) is not found, class will fallback to use the fallback language. If the `$fallback_language.ini` file is also not found, it will throw an error and **exit**.

Example 1
---------

[](#example-1)

File: **/var/www/lang/en.ini**

```
CURRENT_LANG = 'en'
HELLO = 'Hello'
LOGIN = 'Login';
SEARCH = 'Search'
CATEGORIES = 'Categories';
SETTINGS = 'Settings';
PREVIOUS = 'Previous';
NEXT = 'Next';
X='Y';
```

PHP:

```
