PHPackages                             oviedev/toungette - 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. oviedev/toungette

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

oviedev/toungette
=================

Toungette is a small and simple PHP library used to simplify translating your website

1.01(3y ago)215MITPHP

Since Sep 18Pushed 2y ago1 watchersCompare

[ Source](https://github.com/OvieDev/toungette)[ Packagist](https://packagist.org/packages/oviedev/toungette)[ RSS](/packages/oviedev-toungette/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (6)Used By (0)

Toungette
=========

[](#toungette)

[![code cov](https://camo.githubusercontent.com/b54dcbb8c06d081deac646dc8600b254af3691326be0d27deeeebf2e31e0727e/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f4f7669654465762f746f756e67657474653f6c6f676f3d636f6465636c696d617465)](https://camo.githubusercontent.com/b54dcbb8c06d081deac646dc8600b254af3691326be0d27deeeebf2e31e0727e/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f4f7669654465762f746f756e67657474653f6c6f676f3d636f6465636c696d617465)[![code cov](https://camo.githubusercontent.com/fc7f1f006b323bc8893e1b4e5d0931dd9e4285324f857a4a69f8154ab5d99ffe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f4f7669654465762f746f756e67657474653f6c6f676f3d676974687562)](https://camo.githubusercontent.com/fc7f1f006b323bc8893e1b4e5d0931dd9e4285324f857a4a69f8154ab5d99ffe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f4f7669654465762f746f756e67657474653f6c6f676f3d676974687562)[![code cov](https://camo.githubusercontent.com/21d0964bd143042fd89333d1d8883114ae188416fbdc30c2274a00cb0b59f766/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312d626c756576696f6c6574)](https://camo.githubusercontent.com/21d0964bd143042fd89333d1d8883114ae188416fbdc30c2274a00cb0b59f766/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312d626c756576696f6c6574)
*Small and simple PHP library for translating websites*

Introduction
------------

[](#introduction)

Toungette is a PHP library used to simplify translating your website. You only need 3 files to make it work, and you still have full control over your translations without any need to create the same page twice, but with different text.

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

[](#installation)

Before you install it, in your `composer.json` add `"minimum-stability": "rc"`. That's because there is no version of simplehtmldom that is stable (at least on packagist). After you did so, use:
`composer require oviedev/toungette`

Documentation
-------------

[](#documentation)

You can view documentation here: [Documentation](docs/README.md)

How to use
----------

[](#how-to-use)

Let's make a simple website with one page.
Setup 3 files. `schem.json`, `index.tounge` and `index.php`.

`schem.json` is where you define your translations. At the beggining of the file, you need to define `schema` property. It's an array of avaible languages.
Next you have the `keys` object. It stores your translations as arrays. Values of the keys are ordered via `schema`. So let's define two keys. `key.hello` and `key.goodbye`

```
{
  "schema": ["en", "es", "pl"],
  "keys": {
    "key.hello": [
      "Hello",
      "Hola",
      "Hej"
    ],
    "key.goodbye": [
      "Goodbye",
      "Adios",
      "Do widzenia"
    ]
  }
}
```

Let's move to the `index.tounge`. This is where you define, how your page will look. It's plain html, but you start with the `` tag, instead of ``. So our file may look like this:

```

  {key.hello}

  this text isn't affected by translations

  {key.goodbye}

```

Notice that our keys are in curly braces.

Now, it's time for our `index.php` file. This is where the translation magic comes in. It contains every standard tag required for the website (`` and ``), excluding ``

```
DOCTYPE HTML>

    My Toungette Page
