geniv / nette-translator
Translator extension for Nette Framework
Installs: 1 205
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
- dibi/dibi: >=3.0
- geniv/nette-locale: >=2.0
- geniv/nette-search-content: >=1.0
- nette/nette: >=2.4
- dev-master
- v2.3.6
- v2.3.5
- v2.3.4
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.6
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0
- dev-develop
This package is auto-updated.
Last update: 2024-10-27 13:30:26 UTC
README
This translator is target for save ident in message, also default text is for id_locale=NULL, next language must be translate manual.
Plurals source: http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html
Installation
$ composer require geniv/nette-translator
or
"geniv/nette-translator": "^2.0"
require:
"php": ">=7.0", "nette/nette": ">=2.4", "dibi/dibi": ">=3.0", "geniv/nette-locale": ">=2.0", "geniv/nette-search-content": ">=1.0"
Include in application
available source drivers:
- DevNullDriver (ignore translate, only default translate)
- NeonDriver (filesystem in neon syntax)
- DibiDriver (dibi + cache
_Translator-DibiDriver
, self translation db table)
neon configure:
# translator translator: # debugger: true # autowired: true driver: Translator\Drivers\DevNullDriver # driver: Translator\Drivers\NeonDriver(%appDir%) # driver: Translator\Drivers\DibiDriver(%tablePrefix%) # searchMask: # - *Translation.neon searchPath: - %appDir%/../vendor/geniv # first vendor - %appDir% - %appDir%/presenters/CustomTranslation.neon excludePath: - CustomTranslation.neon
searchPath
is configure for system search default translations.
Default translation system has name convection *Translation.neon
, eg: AppTranslation.neon
Names in dirs are sort with function natsort().
It is possible add custom default translate file.
excludePath
is only exclude in search dirs in searchPath
.
This neon file has format: myIndent: "MyDefaultMessage"
WARNING: The identification index should not be the same as the translation itself.
neon configure extension:
extensions: translator: Translator\Bridges\Nette\Extension
usage:
{* standard translating *} {_'preklad'} {* plural translating *} {_'preklad', $pocet} {* substitution translating *} {_'preklad', [$pocet]}
this latte macro is not supported, because like index must use be simple string like {_'xyz'}
:
{_}translate{/_}
presenters:
/** @var ITranslator @inject */ public $translator; $form = new \Nette\Application\UI\Form; $form->setTranslator($this->translator);
or
// standard translating $this->translator->translate('message-ident'); // plural translating $this->translator->translate('message-ident', 123); // inside %s // substitution translating $this->translator->translate('message-ident', [123]); // inside %s // substitution translating $this->translator->translate('message-ident', ['hello', 123]); // inside %s, %s