PHP Classes

File: docs/_sources/getting_started.rst.txt

Recommend this page to a friend!
  Classes of Francesco Danti   ATK4 i18next PHP   docs/_sources/getting_started.rst.txt   Download  
File: docs/_sources/getting_started.rst.txt
Role: Documentation
Content type: text/plain
Description: Documentation
Class: ATK4 i18next PHP
Translate application texts like il8next-PHP
Author: By
Last change:
Date: 4 years ago
Size: 1,405 bytes
 

Contents

Class file image Download
.. _getting_started: Getting started =============== Instantiate .. code-block:: php $translator = new Translator(); Define root path for translations .. code-block:: php $translator->setTranslationsPath('path/to/locales'); (optional) Define if filename has to be used has namespace .. code-block:: php $translator->useFilenameAsNamespace(true); (optional) Define namespaces priority .. code-block:: php $translator->setNamespacePriority('firstNs','secondNs','otherNs'); Define primary and fallback language (name of the folders where library load files) .. code-block:: php $translator->setLanguagePrimary($language); $translator->setLanguageFallback($fallback); Add additional language .. code-block:: php $translator->addLanguage('it'); Usage examples -------------- .. code-block:: php :linenos: $result = $translator->_('definitionKey'); $result = $translator->_('definitionKey', ['param1' => 'test']); $result = $translator->_('definitionKey', ['param1' => 'test'], 'context'); $result = $translator->_('definitionKey', ['param1' => 'test'], 'context', 'specificLanguage'); $result = $translator->_('namespace:definitionKey', ['param1' => 'test'], 'context', 'specificLanguage'); The TranslatorInterface ----------------------- .. literalinclude:: ../../src/I18Next/TranslatorInterface.php :linenos: :language: php