brightnucleus/localization
最新稳定版本:v0.2.0
Composer 安装命令:
composer require brightnucleus/localization
包简介
WordPress localization for Bright Nucleus components.
README 文档
README
WordPress localization for Bright Nucleus components.
Table Of Contents
Installation
The best way to use this package is through Composer:
composer require brightnucleus/localization
Basic Usage
This package provides a trait to be used within Bright Nucleus components to load the translation files (compiled *.mo-files) for a given locale.
To use the trait, import it into your class, and call the loadLocalization( $domain, $path ) method.
Example:
<?php namespace Localization\Example; use BrightNucleus\Localization\LocalizationTrait; class TranslatedClass { use LocalizationTrait; public function register() { $this->loadLocalization( 'bn-localization-example', __DIR__ . '/../languages' ); // Your normal registration comes here, knowing that all `gettext` // strings have already been translated. } }
Filters
Each loading of localization files passes through two filters:
-
Localization::LOCALE_FILTER- Filter the locale of a Bright Nucleus library.Arguments:
$locale(string) - The plugin's current locale.$domain(string) - Text domain. Unique identifier for retrieving translated strings.
Return value:
$locale(string) - Filtered locale.
-
Localization::MOFILE_FILTER- Filter the name of the MO-file of a Bright Nucleus library.Arguments:
$path(string) - Path to the MO-file.$locale(string) - The plugin's current locale.$domain(string) - Text domain. Unique identifier for retrieving translated strings.
Return value:
$path(string) - Fitlered path to the MO-file.
Contributing
All feedback / bug reports / pull requests are welcome.
License
Copyright (c) 2016 Alain Schlesser, Bright Nucleus
This code is licensed under the MIT License.
统计信息
- 总下载量: 15.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-15