PHP Classes

File: docs/source/getting_started.rst

Recommend this page to a friend!
  Classes of Francesco Danti   ATK4 i18next PHP   docs/source/getting_started.rst   Download  
File: docs/source/getting_started.rst
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: ATK4 i18next PHP
Translate application texts like il8next-PHP
Author: By
Last change:
Date: 5 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