{"id":18929432,"url":"https://github.com/thecodingmachine/utils.i18n.fine.translation-interface","last_synced_at":"2026-03-16T14:30:17.665Z","repository":{"id":26450912,"uuid":"29902029","full_name":"thecodingmachine/utils.i18n.fine.translation-interface","owner":"thecodingmachine","description":"This package contains interface to use fine","archived":false,"fork":false,"pushed_at":"2016-07-08T08:28:01.000Z","size":519,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":18,"default_branch":"4.0","last_synced_at":"2025-02-16T12:30:30.886Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecodingmachine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-27T07:09:59.000Z","updated_at":"2016-07-08T08:28:01.000Z","dependencies_parsed_at":"2022-08-29T15:51:34.840Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/utils.i18n.fine.translation-interface","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Futils.i18n.fine.translation-interface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Futils.i18n.fine.translation-interface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Futils.i18n.fine.translation-interface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Futils.i18n.fine.translation-interface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/utils.i18n.fine.translation-interface/tar.gz/refs/heads/4.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239927823,"owners_count":19719835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T11:32:41.488Z","updated_at":"2026-03-16T14:30:17.621Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Internationalisation with FINE\n==============================\n\nFine is a PHP internationalisation package. It will help you develop applications that support several languages.\nFINE means: Fine is not English :).\n\nBy default, translation is performed using PHP mapping files, but other implementation (database storage) can also by used.\nFine is a [Mouf package](http://mouf-php.com).\nThis means you will have a nice graphical interface inside the Mouf framework to write your own translated messages.\n\nIn this document, we will describe how to use FINE to support several languages in your application.\n\nTODO SCREENSHOT INTERFACE !!!\n\nInstall\n=======\n\nDependencies\n------------\n\nFine comes as a *Composer* package and requires the \"Mouf\" framework to run.\nThe first step is therefore to [install Mouf](http://www.mouf-php.com/).\n\nOnce Mouf is installed, you can process to the Fine installation.\n\nInstall Fine\n--------------\n\nEdit your *composer.json* file, and add a dependency on *mouf/utils.i18n.fine*.\n\nA typical *composer.json* file might look like this:\n\n```\n    {\n        \"require\": {\n            \"mouf/mouf\": \"~2.0.0\",\n            \"mouf/utils.i18n.fine.translation-interface\": \"~4.0\",\n            \"mouf/utils.i18n.fine.language-detection\": \"~4.0\",\n            \"mouf/utils.i18n.fine.file-translator\": \"~4.0\",\n            \"mouf/utils.i18n.fine.manage.bo\": \"~4.0\",\n            \"mouf/utils.i18n.fine.common\": \"~4.0\"\n        },\n        \"autoload\": {\n            \"psr-4\": {\n                \"Test\\\\\": \"src/\"\n            }\n        }\n    }\n```\n\nAs you can see, there are a number of packages included:\n\n- [**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...)\n  This package contains the interfaces for language detection and translation system implemented by the other packages.\n- [**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...)\n- [**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:\n    - [**mouf/utils.i18n.fine.bd-translation**](http://mouf-php.com/packages/mouf/utils.i18n.fine.bd-translation/README.md): Store translation in database.\n- [**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. \n- [**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\n\nTo install the package. After yout composer, you must going to the Mouf interface and select Project -\u003e Installation tasks\n![Fine task menu](images/01_task_menu.png)\n\nYou could see the list of fine package that must install to use it.\n![Fine task installtion](images/02_task.png)\n\nClick on button Run the x tasks.\n\nThe installation create all the instance to use fine:\n\n- The FineCacadingTranslator class is to cascading all your translator. If the first doesn't have the translation, the second is requested.... \nThe first translator how has the response is returned. So the order of translators is very important.\n\n- Found the defaultTranslationService instance in Mouf, click on it.\nThere is a table of TranslatorInterface\n![Fine default instance screenshot](images/03_default_instance.png)\n\n- To add a new instance, please click on add an instance, don't forget to configure it!\n![Fine add instance screenshot](images/04_add_instance.png)\n\n- To change the order, just drag and drop the instance before or after another\n![Fine instance order screenshot](images/05_instance_order.png)\n\nYour package is ready for the code!\n\n\n\n\nUsing interface\n---------------\n\n### Create a translation\n\nThis interface can be use to add, edit or delete a translation.\nYou can access to this interface with the menu HTML -\u003e Fine -\u003e Manage Translation.\n![Fine install menu screenshot](images/06_menu.png)\n\nOn this interface there is a button to add a new translation.\n![Fine install interface screenshot](images/07_interface.png)\n\nA modal appears, in the title input you can set your fine key, in this example it's \"test.key\".\nSelect you language, for example english and add it ith the \"add\" button.\n![Fine install new translation screenshot](images/08_new_translation.png)\n\nEnter a message in the text zone. And click on the \"Save all Translations\" button.\n![Fine install message screenshot](images/09_message.png)\n\nIn this page you can see your translation.\n![Fine install display screenshot](images/10_display.png)\n\nThe top right select is to diplay the language at the bottom of the modal. With this translation you can easily translate all message.\n![Fine install translation screenshot](images/11_translation.png)\n\n### Edit translation\n\nTo edit a translation click on the key or directly on the translation.\nYou can add a new language with the \"add\" tab in the modal.\n\n### Remove a translation\n\nYou can remove a translation with the cross on the language.\nAfter you can validate to remove only this language\n![Fine install remove translation screenshot](images/12_remove_translation.png)\n\nTo remove the full key, click on the bottom button \"remove key\" and validate it.\n![Fine install remove key screenshot](images/13_remove_key.png)\n\n\nIn your code\n------------\n\nIn your code, you can use the functions. There are bind automatically to the defaultTranslationService:\n\n- iMsg function: Return the translation of the key, parameters (in option) and LanguageDetection (in option)\n- eMsg function: Do an echo of iMsg\n\nExample:\n```php\n$string = iMsg('mykey', array('parameter1' =\u003e 'value'));\neMsg('mykey', array('parameter1' =\u003e 'value'));\n```\nThe messagethe key mykey is: \"A test with {parameter1}\"\n\nIt's possible to add an instance of LanguageDetectionInterface (for exemple to change the language in the middle of your code).\nExample:\nIn this controller you have bind an instance of LanguageDetetionInterface named $fixEnglishLanguage\nSo you can call the function with\n```\niMsg('myKey', array('parameter1' =\u003e 'value'), $this-\u003efixEnglishLanguage);\n```\n\nInterface Implementation\n========================\n\nIf you want to create your own package, you can see [the implementation](doc/implementation.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Futils.i18n.fine.translation-interface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Futils.i18n.fine.translation-interface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Futils.i18n.fine.translation-interface/lists"}