3 个不稳定版本

0.2.0 2023年3月31日
0.1.1 2023年3月22日
0.1.0 2023年3月21日

文本处理 中排名第 1427

每月下载量 39

MIT 许可证

11KB
130

simple-localization

简单的本地化库


用法

此目录树必须位于您的项目中

├── Cargo.lock
├── Cargo.toml
├── localization
   └── tr_TR # Add files here
└── src
    └── lib.rs

在本地化文件内部(例如: localization/tr_TR):

// One Line Example
"Hello" => "Merhaba"
"How are you?" => "Nasılsın?"
"This is a long text" => "Bu uzun bir yazı"

// Multiline Example
#"This is a multiline text.

You can write anything you want here.

Don't need to use \n.

The translation of this is next the quoted text."#
=>
#"Bu bir çok satırlı yazı.

Buraya istediğin her şeyi yazabilirsin.

\n kullanman gerekmez.

Bu yazının çevirisi bir sonraki tırnak içindeki yazıdır."#

tr() 在您的 main.rs 中的用法

use simple_localization::tr;

// localization/tr_TR file exists and `LANG=tr_TR.UTF-8`
let text:&str = tr("Hello"); // "Merhaba"

// localization/tr_TR file doesn't exists and `LANG=tr_TR.UTF-8`
let text:&str = tr("Hello"); // "Hello"

// localization/ar_QA file doesn't exists and `LANG=ar_QA.UTF-8`
let text:&str = tr("Hello"); // "Hello"

trl() 在您的 main.rs 中的用法

use simple_localization::trl;

// localization/tr_TR file exists
let text:&str = trl("Hello", "tr_TR"); // "Merhaba"

// localization/ar_QA file exists
let text:&str = trl("Hello", "ar_QA"); // "مرحبًا"

// localization/tr_TR file doesn't exists
let text:&str = trl("Hello", "tr_TR"); // "Hello"

依赖关系

约3.5–4.5MB
约90K SLoC