1use tauri::{
2 plugin::{Builder, TauriPlugin},
3 Manager, Runtime,
4};
5
6pub use models::*;
7
8mod backend;
9mod commands;
10mod error;
11mod models;
12
13pub use error::{Error, Result};
14
15pub fn init<R: Runtime>(locale: Option<String>) -> TauriPlugin<R> {
17 Builder::new("i18n")
18 .invoke_handler(tauri::generate_handler![
19 commands::load_translations,
20 commands::translate,
21 commands::set_locale,
22 commands::get_locale,
23 commands::get_available_locales,
24 ])
25 .setup(|app, _api| {
26 app.manage(PluginI18n::new(
27 app.clone(),
28 locale.unwrap_or("en".to_string()),
29 ));
30
31 Ok(())
32 })
33 .build()
34}