PHPackages                             dasred/translation - 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. dasred/translation

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

dasred/translation
==================

v1.0.15(9y ago)01.7k1PHPPHP &gt;=5.5

Since Jul 20Pushed 9y ago1 watchersCompare

[ Source](https://github.com/DasRed/translation)[ Packagist](https://packagist.org/packages/dasred/translation)[ Docs](https://github.com/DasRed/translation)[ RSS](/packages/dasred-translation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (19)Used By (1)

General
=======

[](#general)

This is a simple translation engine.

Installation
============

[](#installation)

```
composer install dasred/translation
```

Usage
=====

[](#usage)

File structure
--------------

[](#file-structure)

The [translator](src/Translator.php) requires at least 2 arguments. The first argument is the current locale. The second argument is the path, in which are located the translation files.

The following structure for translation files in the given directory will be used.

```
given translation directory
|--- de_DE
       |--- general.php
       |--- account.php
       |--- other.php
|--- en_GB
       |--- general.php
       |--- account.php
       |--- other.php

```

The third argument defines the default locale of the [translator](src/Translator.php). The default locale will be used as fallback. If a translation key not defined in the current locale, the key will be searched in the default locale.

Every translation file must return an array key value list. The key is a part of the translation key and the value is the translation.

The following example show the file de\_DE/general.php

```
