| Crates.io | tauri-plugin-locale |
| lib.rs | tauri-plugin-locale |
| version | 2.0.1 |
| created_at | 2025-03-24 15:07:31.890196+00 |
| updated_at | 2025-03-24 15:24:43.643401+00 |
| description | get the locale of the system. |
| homepage | |
| repository | https://github.com/ayangweb/tauri-plugin-locale |
| max_upload_size | |
| id | 1603866 |
| size | 216,850 |
This plugin only works on tauri v2, if you need the v1 plugin, feel free to submit a PR!
Why not use the locale method provided by tauri?
For example:
zh-Hans-CN → This plugin: zh-CNzh-Hant-TW → This plugin: zh-TWThis simplified format is widely used in web development and i18n libraries, omitting script tags (Hans/Hant) for better compatibility.
| Platform | Supported |
|---|---|
| Windows | ✅ |
| macOS | ✅ |
| Linux | ✅ |
| Android | ❌ |
| iOS | ❌ |
cargo add tauri-plugin-locale
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
pnpm add tauri-plugin-locale-api
src-tauri/src/lib.rs
pub fn run() {
tauri::Builder::default()
+ .plugin(tauri_plugin_locale::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
src-tauri/capabilities/default.json
{
...
"permissions": [
...
+ "locale:default"
]
}
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
import { getLocale } from "tauri-plugin-locale-api";
const locale = await getLocale();
console.log(locale); // en-US
| Method | Description |
|---|---|
getLocale |
Get the locale of the system. |