mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
l10n: adjust the documentation
This commit is contained in:
+7
-8
@@ -66,30 +66,29 @@ You can override the locale at runtime by running:
|
||||
|
||||
## 📥 Retrieving Messages
|
||||
|
||||
Two APIs are available:
|
||||
We have a single macro to handle translations.
|
||||
It can be used in two ways:
|
||||
|
||||
### `get_message(id: &str) -> String`
|
||||
### `translate!(id: &str) -> String`
|
||||
|
||||
Returns the message from the current locale bundle.
|
||||
|
||||
```
|
||||
let msg = get_message("id-greeting");
|
||||
let msg = translate!("id-greeting");
|
||||
```
|
||||
|
||||
If not found, falls back to `en-US`. If still missing, returns the ID itself.
|
||||
|
||||
---
|
||||
|
||||
### `get_message_with_args(id: &str, args: HashMap<String, String>) -> String`
|
||||
### `translate!(id: &str, args: key-value pairs) -> String`
|
||||
|
||||
Supports variable interpolation and pluralization.
|
||||
|
||||
```
|
||||
let msg = get_message_with_args(
|
||||
let msg = translate!(
|
||||
"error-io",
|
||||
HashMap::from([
|
||||
("error".to_string(), std::io::Error::last_os_error().to_string())
|
||||
])
|
||||
"error" => std::io::Error::last_os_error()
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user