leodido/langcode-conv
最新稳定版本:v0.3.0
Composer 安装命令:
composer require leodido/langcode-conv
包简介
Convert language codes to any available format
关键字:
README 文档
README
This library, based on conversio library, is aimed to convert every existing language code to any format you want. No matter which format the input language code is.
Details
The available output formats are:
-
nameThe international (often english) name of the language
-
nativeThe language name written in native representation/s
-
iso639-1The ISO 639-1 (two-letters code) language representation
-
iso639-2/tThe ISO 639-2/T (three-letters code for terminology applications) language representation
-
iso639-2/bThe ISO 639-2/B (three-letters code, for bibliographic applications) language representation
-
iso639-3The ISO 639-3 (same as ISO 639-2/T except that for the macrolanguages) language representation
Currently 184 languages are fully supported.
Examples
First of all you need to create the conversion adapter and its options class.
use Conversio\Conversion; use Conversio\Adapter\LanguageCode; use Conversio\Adapter\Options\LanguageCode; // ... $adapter = new LanguageCode(); $options = new LanguageCodeOptions();
Then, you can pass it to the Conversion class constructor (from conversio library):
$converter = new Conversion($adapter); $converter->setAdapterOptions($options);
Or, compactly:
$converter = new Conversion(['adapter' => $adapter, 'options' => $options]);
Finally we need to specify the desired output format (see above the supported formats) of the conversion and perform it.
$options->setOutput('native'); // ISO 639-1 => NATIVE $converter->filter('it'); // italiano
Which ouputs, in this case italiano.
Have fun, try other language codes (e.g., vie, tam).
// ISO 639-2/T => NATIVE $converter->filter('vie'); // tiếng việt $converter->filter('tam'); // தமிழ் // ISO 639-3 => NATIVE $converter->filter('yid + 2'); // ייִדיש // ISO 639-3 => NAME $options->setOutput('name'); $converter->filter('vie'); // vietnamese $converter->filter('tam'); // tamil $converter->filter('yid + 2'); // yiddish
Installation
Add leodido/langcode-conv to your composer.json.
{
"require": {
"leodido/langcode-conv": "v0.3.0"
}
}
References
统计信息
- 总下载量: 52.21k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: ISC
- 更新时间: 2015-01-09