Tauri commands
The #[tauri::command] functions in crates/tauri-plugin-i18n-next/src/commands.rs, called with invoke('plugin:i18n-next|<name>', args).
You normally use the JavaScript API instead. Arguments are sent in camelCase
(Rust names as is for rename_all = "snake_case"); parameters injected by Tauri (AppHandle, State,
Window, WebviewWindow, Webview, ipc::Request) are not listed.
| Command | Description |
|---|---|
load | Start: the active chain's roots and, with page, its page chunks, plus locales, defaultLocale and the named formats (the payload of i18n_next::payload), as raw bytes. |
meta | What the front end needs to start and to build protocol URLs, without the chunks: version, locale, defaultLocale, fallbackLocale, locales, chains (the fallback chain of every locale, which the front end premerges in order), the named formats, tags (the content tag of each chunk of the chain of locale, the active one when not given, roots and page, by "<locale>/<page>") and bundle (the tag of its protocol bundle). |
load_page | Navigation: the page chunks of the active chain, as raw bytes. |
set_locale | Switches the locale for Rust, native labels and every window (they get crate::EVENT_CHANGED); returns the new catalog version. |
get_locale | The active locale. |
available_locales | Locales that are not disabled: i18n.json order first, then the rest by code. |
pages | Known page names, sorted. |
report_missing | Keys the front end missed (dev builds only: the plugin registers it in debug). |
Commands
load
Start: the active chain's roots and, with page, its page chunks, plus locales,
defaultLocale and the named formats (the payload of i18n_next::payload), as raw
bytes. languages (navigator.languages) picks the start locale on the first call
when no saved one applies; timeZone (the WebView's zone) is the system zone
of dates unless the catalog has one (webview_zone). The fallback path when the
protocol is unavailable.
invoke('plugin:i18n-next|load', { page, languages, timeZone })
| Argument (JS) | Rust parameter | Type |
|---|---|---|
page | page | Option<String> |
languages | languages | Option<Vec<String>> |
timeZone | time_zone | Option<String> |
Returns Response. Rust: plain (sync) fn. Permission: i18n-next:allow-load.
meta
What the front end needs to start and to build protocol URLs, without the chunks:
version, locale, defaultLocale, fallbackLocale, locales, chains (the
fallback chain of every locale, which the front end premerges in order),
the named formats, tags (the content tag of each chunk of the chain of locale, the
active one when not given, roots and page, by "<locale>/<page>") and bundle (the
tag of its protocol bundle). As raw bytes, like load. languages
(navigator.languages) picks the start locale like the first load does, so a
front end that reads data over the protocol never needs load; timeZone likewise
gives the WebView's zone (webview_zone), and the answer's timeZone is the zone
dates show in when it is known by name.
invoke('plugin:i18n-next|meta', { locale, page, languages, timeZone })
| Argument (JS) | Rust parameter | Type |
|---|---|---|
locale | locale | Option<String> |
page | page | Option<String> |
languages | languages | Option<Vec<String>> |
timeZone | time_zone | Option<String> |
Returns Response. Rust: plain (sync) fn. Permission: i18n-next:allow-meta.
load_page
Navigation: the page chunks of the active chain, as raw bytes.
invoke('plugin:i18n-next|load_page', { page })
| Argument (JS) | Rust parameter | Type |
|---|---|---|
page | page | String |
Returns Response. Rust: plain (sync) fn. Permission: i18n-next:allow-load-page.
set_locale
Switches the locale for Rust, native labels and every window (they get
crate::EVENT_CHANGED); returns the new catalog version.
invoke('plugin:i18n-next|set_locale', { locale })
| Argument (JS) | Rust parameter | Type |
|---|---|---|
locale | locale | String |
Returns u64. Rust: plain (sync) fn. Permission: i18n-next:allow-set-locale.
get_locale
The active locale.
invoke('plugin:i18n-next|get_locale')
No arguments.
Returns String. Rust: plain (sync) fn. Permission: i18n-next:allow-get-locale.
available_locales
Locales that are not disabled: i18n.json order first, then the rest by code.
invoke('plugin:i18n-next|available_locales')
No arguments.
Returns Vec<Locale>. Rust: plain (sync) fn. Permission: i18n-next:allow-available-locales.
pages
Known page names, sorted.
invoke('plugin:i18n-next|pages')
No arguments.
Returns Vec<String>. Rust: plain (sync) fn. Permission: i18n-next:allow-pages.
report_missing
Keys the front end missed (dev builds only: the plugin registers it in debug). They join the Rust misses in the report.
invoke('plugin:i18n-next|report_missing', { keys })
| Argument (JS) | Rust parameter | Type |
|---|---|---|
keys | keys | Vec<MissingKey> |
Returns (). Rust: plain (sync) fn. Permission: i18n-next:allow-report-missing.