PHPackages                             mouf/utils.i18n.fine.translation-interface - 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. mouf/utils.i18n.fine.translation-interface

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

mouf/utils.i18n.fine.translation-interface
==========================================

This package contains two interfaces shared by all translation services. The LanguageDetectionInterface is used to detect the current language for the user while the TranslatorInterface is used to translate strings.

4.0.x-dev(9y ago)017.8k5MITPHPPHP &gt;=5.4.0

Since Jul 8Pushed 9y ago16 watchersCompare

[ Source](https://github.com/thecodingmachine/utils.i18n.fine.translation-interface)[ Packagist](https://packagist.org/packages/mouf/utils.i18n.fine.translation-interface)[ Docs](https://mouf-php.com/mouf/utils.i18n.fine.translation-interface)[ RSS](/packages/mouf-utilsi18nfinetranslation-interface/feed)WikiDiscussions 4.0 Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (5)

Internationalisation with FINE
==============================

[](#internationalisation-with-fine)

Fine is a PHP internationalisation package. It will help you develop applications that support several languages. FINE means: Fine is not English :).

By default, translation is performed using PHP mapping files, but other implementation (database storage) can also by used. Fine is a [Mouf package](http://mouf-php.com). This means you will have a nice graphical interface inside the Mouf framework to write your own translated messages.

In this document, we will describe how to use FINE to support several languages in your application.

TODO SCREENSHOT INTERFACE !!!

Install
=======

[](#install)

Dependencies
------------

[](#dependencies)

Fine comes as a *Composer* package and requires the "Mouf" framework to run. The first step is therefore to [install Mouf](http://www.mouf-php.com/).

Once Mouf is installed, you can process to the Fine installation.

Install Fine
------------

[](#install-fine)

Edit your *composer.json* file, and add a dependency on *mouf/utils.i18n.fine*.

A typical *composer.json* file might look like this:

```
    {
        "require": {
            "mouf/mouf": "~2.0.0",
            "mouf/utils.i18n.fine.translation-interface": "~4.0",
            "mouf/utils.i18n.fine.language-detection": "~4.0",
            "mouf/utils.i18n.fine.file-translator": "~4.0",
            "mouf/utils.i18n.fine.manage.bo": "~4.0",
            "mouf/utils.i18n.fine.common": "~4.0"
        },
        "autoload": {
            "psr-4": {
                "Test\\": "src/"
            }
        }
    }

```

As you can see, there are a number of packages included:

- [**mouf/utils.i18n.fine.translation-interface**](http://mouf-php.com/packages/mouf/utils.i18n.fine.translation-interface/README.md): Fine is a modular package. You can replace any part of it (language detection, translation system, etc...) This package contains the interfaces for language detection and translation system implemented by the other packages.
- [**mouf/utils.i18n.fine.language-detection**](http://mouf-php.com/packages/mouf/utils.i18n.fine.language-detection/README.md): This package contains the classes used to detect the language of the user (based on the browser, or the session, etc...)
- [**mouf/utils.i18n.fine.file-translation**](http://mouf-php.com/packages/mouf/utils.i18n.fine.file-translator/README.md): There is many solution to store the translation. By default, the file storage is enabled. There is other package:
    - [**mouf/utils.i18n.fine.bd-translation**](http://mouf-php.com/packages/mouf/utils.i18n.fine.bd-translation/README.md): Store translation in database.
- [**mouf/utils.i18n.fine.manage.bo**](http://mouf-php.com/packages/mouf/utils.i18n.fine.manage.bo/README.md): To manage translations, this package adds a human interface in Mouf to add, edit or delete a translation.
- [**mouf/utils.i18n.fine.common**](http://mouf-php.com/packages/mouf/utils.i18n.fine.common/README.md): This package contains the installer to help the user to install all the great packages to start and all the interface, function or trait to use fine or implement it

To install the package. After yout composer, you must going to the Mouf interface and select Project -&gt; Installation tasks [![Fine task menu](images/01_task_menu.png)](images/01_task_menu.png)

You could see the list of fine package that must install to use it. [![Fine task installtion](images/02_task.png)](images/02_task.png)

Click on button Run the x tasks.

The installation create all the instance to use fine:

- The FineCacadingTranslator class is to cascading all your translator. If the first doesn't have the translation, the second is requested.... The first translator how has the response is returned. So the order of translators is very important.
- Found the defaultTranslationService instance in Mouf, click on it. There is a table of TranslatorInterface [![Fine default instance screenshot](images/03_default_instance.png)](images/03_default_instance.png)
- To add a new instance, please click on add an instance, don't forget to configure it! [![Fine add instance screenshot](images/04_add_instance.png)](images/04_add_instance.png)
- To change the order, just drag and drop the instance before or after another [![Fine instance order screenshot](images/05_instance_order.png)](images/05_instance_order.png)

Your package is ready for the code!

Using interface
---------------

[](#using-interface)

### Create a translation

[](#create-a-translation)

This interface can be use to add, edit or delete a translation. You can access to this interface with the menu HTML -&gt; Fine -&gt; Manage Translation. [![Fine install menu screenshot](images/06_menu.png)](images/06_menu.png)

On this interface there is a button to add a new translation. [![Fine install interface screenshot](images/07_interface.png)](images/07_interface.png)

A modal appears, in the title input you can set your fine key, in this example it's "test.key". Select you language, for example english and add it ith the "add" button. [![Fine install new translation screenshot](images/08_new_translation.png)](images/08_new_translation.png)

Enter a message in the text zone. And click on the "Save all Translations" button. [![Fine install message screenshot](images/09_message.png)](images/09_message.png)

In this page you can see your translation. [![Fine install display screenshot](images/10_display.png)](images/10_display.png)

The top right select is to diplay the language at the bottom of the modal. With this translation you can easily translate all message. [![Fine install translation screenshot](images/11_translation.png)](images/11_translation.png)

### Edit translation

[](#edit-translation)

To edit a translation click on the key or directly on the translation. You can add a new language with the "add" tab in the modal.

### Remove a translation

[](#remove-a-translation)

You can remove a translation with the cross on the language. After you can validate to remove only this language [![Fine install remove translation screenshot](images/12_remove_translation.png)](images/12_remove_translation.png)

To remove the full key, click on the bottom button "remove key" and validate it. [![Fine install remove key screenshot](images/13_remove_key.png)](images/13_remove_key.png)

In your code
------------

[](#in-your-code)

In your code, you can use the functions. There are bind automatically to the defaultTranslationService:

- iMsg function: Return the translation of the key, parameters (in option) and LanguageDetection (in option)
- eMsg function: Do an echo of iMsg

Example:

```
$string = iMsg('mykey', array('parameter1' => 'value'));
eMsg('mykey', array('parameter1' => 'value'));
```

The messagethe key mykey is: "A test with {parameter1}"

It's possible to add an instance of LanguageDetectionInterface (for exemple to change the language in the middle of your code). Example: In this controller you have bind an instance of LanguageDetetionInterface named $fixEnglishLanguage So you can call the function with

```
iMsg('myKey', array('parameter1' => 'value'), $this->fixEnglishLanguage);

```

Interface Implementation
========================

[](#interface-implementation)

If you want to create your own package, you can see [the implementation](doc/implementation.md)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3601d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1104771?v=4)[mouf](/maintainers/mouf)[@Mouf](https://github.com/Mouf)

---

Top Contributors

[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (1 commits)")

---

Tags

i18ntranslationmouf

### Embed Badge

![Health badge](/badges/mouf-utilsi18nfinetranslation-interface/health.svg)

```
[![Health](https://phpackages.com/badges/mouf-utilsi18nfinetranslation-interface/health.svg)](https://phpackages.com/packages/mouf-utilsi18nfinetranslation-interface)
```

###  Alternatives

[jenssegers/date

A date library to help you work with dates in different languages

1.8k11.2M80](/packages/jenssegers-date)[gettext/gettext

PHP gettext manager

70130.2M102](/packages/gettext-gettext)[fightbulc/moment

Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js

9693.2M10](/packages/fightbulc-moment)[jms/translation-bundle

Puts the Symfony Translation Component on steroids

42510.8M63](/packages/jms-translation-bundle)[lexik/translation-bundle

This bundle allows to import translation files content into the database and provide a GUI to edit translations.

4362.7M19](/packages/lexik-translation-bundle)[sonata-project/translation-bundle

SonataTranslationBundle

771.7M10](/packages/sonata-project-translation-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
