lafourchette/l10n-bundle
最新稳定版本:v1.7.1
Composer 安装命令:
composer require lafourchette/l10n-bundle
包简介
A bundle to manage localization
关键字:
README 文档
README
Overview
The aim of L10nBundle is to provide a very simple way to deal with L10N, like I18N with Symfony translator.
L10N data can be store wherever you want. Currently, L10nBundle supports YaML file and MongoDb.
Configuration
Global
l10n:
localization_fallback: en # Fallback localization, used when no explicit Localization is asked or localization not found. Value may be string or integer
locale_fallback: en_US # Fallback locale, to manage L10N values
manager: yaml # The name of the manager you want to use currently yaml or mongodb
You can use the parameters of your symfony configuration in your values. Example:
#parameters.yml
parameters:
my_environment_extension: local
#l10n.yml
l10n:
my_url:
gb: www.domain.%my_environment_extension%
The value will be resolved like this:
my_url => www.domain.local
yaml
yaml:
data_file: /path/to/main.yaml
You can import files
imports:
- { resource: "../../src/Bundle/MyBundle/Resources/translations/l10n.yml" }
Configuration is under l10n key
l10n:
registration:
label:
fr: FRA
es: SPA
name:
fr: french name
es: spanish name
You can use the keys registration.label and registration.name.
Simple translation is provided
Use an array as value:
l10n:
registration.label:
fr:
- {locale: fr, value: FRA_fr}
- {locale: en, value: FRA_en}
mongodb
mongodb:
host: 127.0.0.1
port: 27017
username: test
password: T3$t
database: test_db
Usage
PHP
Example in a controler
$l10n = $this->getContainer()->get('l10n_bundle.business.l10n_provider');
$l10n->getL10n('key', 'idLoc');
Twig
In a twig template you can use the l10n filter
{{ 'key'|l10n }}
You can also provide parameters such as the default localization and/or the locale.
{{ 'key'|l10n('es', 'ca') }}
统计信息
- 总下载量: 74.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0
- 更新时间: 2014-07-08