PHPackages                             crosa7/leaf-omniglot - 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. crosa7/leaf-omniglot

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

crosa7/leaf-omniglot
====================

A Leaf module to add multi language capabilities to leaf applications

1.0.1(2y ago)663MITPHPCI passing

Since Oct 13Pushed 11mo ago2 watchersCompare

[ Source](https://github.com/crosa7/leaf-omniglot)[ Packagist](https://packagist.org/packages/crosa7/leaf-omniglot)[ RSS](/packages/crosa7-leaf-omniglot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

 [![](https://camo.githubusercontent.com/e83224618735d048f0f70f04e02d7973a634a055e18d47fe22501e3a85e40b9f/68747470733a2f2f6c6561667068702e6e65746c6966792e6170702f6173736574732f696d672f6c656166332d6c6f676f2e706e67)](https://camo.githubusercontent.com/e83224618735d048f0f70f04e02d7973a634a055e18d47fe22501e3a85e40b9f/68747470733a2f2f6c6561667068702e6e65746c6966792e6170702f6173736574732f696d672f6c656166332d6c6f676f2e706e67)

Leaf Omniglot
=============

[](#leaf-omniglot)

[![Latest Stable Version](https://camo.githubusercontent.com/d6029fa81f2846757b8013cf6cc640d64692feab25f9c94b75aa8dd41b588da7/687474703a2f2f706f7365722e707567782e6f72672f63726f7361372f6c6561662d6f6d6e69676c6f742f76)](https://packagist.org/packages/crosa7/leaf-omniglot)[![Total Downloads](https://camo.githubusercontent.com/a559be0420142b41fd5abe6cd905980a04b34feecb9549b91957a4bed70368b2/687474703a2f2f706f7365722e707567782e6f72672f63726f7361372f6c6561662d6f6d6e69676c6f742f646f776e6c6f616473)](https://packagist.org/packages/crosa7/leaf-omniglot)[![License](https://camo.githubusercontent.com/b8774df1e20214d173b3de294256b329f93fdb30443c0addb8ea651db121f9a6/687474703a2f2f706f7365722e707567782e6f72672f63726f7361372f6c6561662d6f6d6e69676c6f742f6c6963656e7365)](https://packagist.org/packages/crosa7/leaf-omniglot)

Leaf Omniglot is a simple but powerful module that adds multi language capabilities to your leaf applications.

Installation
------------

[](#installation)

You can easily install Leaf Omniglot using [Composer](https://getcomposer.org/).

```
composer require crosa7/leaf-omniglot
```

Quick Start Guide
-----------------

[](#quick-start-guide)

### Create translation folder and files

[](#create-translation-folder-and-files)

```
// Create a folder named "locales" in your project root
// (you can also create in another place that makes more sense, just be aware to configure the path accordingly)

// Create the following file inside the "locales" folder
en_US.locale.json

// With the following content
{
    "welcome.title": "Hello World"
}
```

### Initialize Omniglot

[](#initialize-omniglot)

In your index.php file (if using MVC: public/index.php). Add these lines:

```
omniglot()->init(
    [
        'TRANSLATION_FILES_LOCATION' => './locales',
    ]
);
```

### Add Language Switch Route

[](#add-language-switch-route)

In your routes file ("\_app.php" for MVC and "index.php" for base Leaf) add this line:

```
omniglot()->addLanguageSwitchRoute();
```

### Start Translating

[](#start-translating)

Now in your template file you can add the following:

(this example is using **laravel blade** as template engine but you can adjust according to your template engine)

```

    @foreach(omniglot()->getAvailableLocales() as $locale)
        getCurrentLocale() === $locale ? 'selected' : '' }}>{{ $locale }}
    @endforeach

{{ tl('welcome.title') }}
```

Or in a simple index.php file

```
