#tauri-plugin #locale #tauri

sys tauri-plugin-locale

get the locale of the system

2 stable releases

2.0.1 Mar 24, 2025

#164 in Internationalization (i18n)

Download history 158/week @ 2025-06-11 108/week @ 2025-06-18 93/week @ 2025-06-25 102/week @ 2025-07-02 107/week @ 2025-07-09 80/week @ 2025-07-16 47/week @ 2025-07-23 56/week @ 2025-07-30 48/week @ 2025-08-06 108/week @ 2025-08-13 127/week @ 2025-08-20 134/week @ 2025-08-27 162/week @ 2025-09-03 177/week @ 2025-09-10 198/week @ 2025-09-17 140/week @ 2025-09-24

696 downloads per month

MIT license

66KB
50 lines

tauri-plugin-locale

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:

  • Tauri: zh-Hans-CN → This plugin: zh-CN
  • Tauri: zh-Hant-TW → This plugin: zh-TW

This simplified format is widely used in web development and i18n libraries, omitting script tags (Hans/Hant) for better compatibility.

Platform Support

Platform Supported
Windows
macOS
Linux
Android
iOS

Install

cargo add tauri-plugin-locale

You can install the JavaScript Guest bindings using your preferred JavaScript package manager:

pnpm add tauri-plugin-locale-api

Usage

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

Methods

Method Description
getLocale Get the locale of the system.

Thanks

Who's Use It

  • EcoPaste - Open source cross-platform clipboard management tool.

Dependencies

~16–63MB
~870K SLoC