12 个版本

新增 0.1.12 2024 年 8 月 10 日
0.1.11 2024 年 8 月 10 日
0.1.9 2024 年 7 月 21 日
0.1.6 2024 年 6 月 6 日

77国际化 (i18n) 中排名

Download history 532/week @ 2024-06-03 3/week @ 2024-06-10 10/week @ 2024-07-01 203/week @ 2024-07-15 135/week @ 2024-07-22 34/week @ 2024-07-29 188/week @ 2024-08-05

每月 560 次下载

自定义许可证

5KB

我的 i18n Rust 库

功能

  • 完全在编译时(不应在任何情况下崩溃或遇到运行时问题,任何运行时的问题都应报告为问题)
  • [x] 支持参数(未命名,它使用 format!() 在底层,请参阅其文档了解所有特性)
  • 支持命名参数(形式为 $argument_name
  • 后备语言选择(目前,总是 en-US

示例

///This macro generates a function per translation key inside the specified struct.
#[tiny_i18n::i18n("path_of_the_translations_directory")] //defaults to `i18n` if called without argument
pub(crate) struct I18n;

fn main() {
    // Each translation key generates a function (every non-ASCII letter, number or underscore are removed)
    println!("{}", I18n::hello_world("en-us")); //the first argument is the language, the following are the arguments, if any
}

结构如下

└── *The name of your i18n folder*
    └── en-US
        └── *You can put as many files as you want (with any/no extension) inside each language folder (or inside any subfolder (as many subfolders as you want)), the name of the file (without the extension) is the id of the translation*
    └── *Other languages*

依赖项

~265–710KB
~17K SLoC