3 个版本
0.0.3 | 2023 年 1 月 24 日 |
---|---|
0.0.2 | 2023 年 1 月 23 日 |
0.0.1 | 2023 年 1 月 23 日 |
116 在 国际化(i18n) 中
123 每月下载量
2MB
108K SLoC
rust_iso/iso639
一个提供 ISO 639 1、ISO 639 2、ISO 639 3、ISO 15924 支持的 rust 包。
什么是 ISO 639
ISO 639 是一种用于分类语言的标准化命名法。每种语言都被分配了一个两字母(639-1)和三个字母(639-2 和 639-3)的小写缩写,这些缩写在命名法的后续版本中进行了修订。
此表列出了所有
ISO 639-1:每个 ISO 639 宏语言一种两字母代码,以及一些
ISO 639-2/T:与 639-1 相同语言的三字母代码
ISO 639-2/B:与 639-2/T 大多数相同的三字母代码,但一些代码来自语言的名字而非本地名称(在以下表中,这些不同的代码用粗体突出显示)
ISO 639-3:与 639-2/T 相同语言的三字母代码,但对于 ISO 639 宏语言的每个变体都有不同的代码
-- 维基百科
安装
[dependencies]
rust_iso639 = "0.0.1"
许可证
rust-iso/rust_iso639 采用 Apache-2.0 许可证。
使用
请参阅文档中的 使用 部分。
快速指南
let lang = rust_iso639::from_code("zh");
let lang = rust_iso639::from_code_2t("zho");
let lang = rust_iso639::from_code_2b("chi");
let lang = rust_iso639::from_code_3("zho");
println!("{:?}", rust_iso639::ALL_CODE);
println!("{:?}", rust_iso639::ALL_CODE_2T);
println!("{:?}", rust_iso639::ALL_CODE_2B);
println!("{:?}", rust_iso639::ALL_CODE_3);
println!("{:?}", rust_iso639::CODE_MAP);
println!("{:?}", rust_iso639::CODE_2T_MAP);
println!("{:?}", rust_iso639::CODE_2B_MAP);
println!("{:?}", rust_iso639::CODE_3_MAP);
数据样本
pub struct LanguageCode<'a> {
///ISO Language Name
pub name: &'static str,
///639-1
pub code: &'static str,
///639-2/T
pub code_2t: &'static str,
///639-2/B
pub code_2b: &'static str,
//639-3 Macrolanguage
pub code_3: &'static str,
pub individual_languages: &'a [IndividualLanguages],
}
#[derive(Debug, Copy, Clone)]
pub struct IndividualLanguages {
///Name
pub name: &'static str,
///Code
pub code: &'static str,
}
来源
- https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
- https://en.wikipedia.org/wiki/ISO_639_macrolanguage
- https://www.rfc-editor.org/rfc/bcp/bcp47.txt
- http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
- https://www.alchemysoftware.com/livedocs/ezscript/Topics/Catalyst/Language.htm
- 脚本名称表示法代码
- https://www.zhihu.com/question/21980689
- https://en.wikipedia.org/wiki/Language_code
- https://iso639-3.sil.org/code_tables/download_tables
- http://unicode.org/iso15924/
依赖
~0.7–9.5MB
~77K SLoC