{"id":13597355,"url":"https://github.com/mondeja/leptos-fluent","last_synced_at":"2025-12-29T21:25:20.163Z","repository":{"id":221464868,"uuid":"754439640","full_name":"mondeja/leptos-fluent","owner":"mondeja","description":"Internationalization framework for Leptos using Fluent","archived":false,"fork":false,"pushed_at":"2025-03-18T17:15:28.000Z","size":2885,"stargazers_count":52,"open_issues_count":13,"forks_count":14,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T14:17:26.985Z","etag":null,"topics":["fluent","fluent-templates","framework","i18n","internationalization","leptos","leptos-fluent","reactive","translation"],"latest_commit_sha":null,"homepage":"https://mondeja.github.io/leptos-fluent/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mondeja.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-08T03:44:02.000Z","updated_at":"2025-03-25T00:09:05.000Z","dependencies_parsed_at":"2024-03-09T17:29:53.287Z","dependency_job_id":"f056ad02-434a-438e-bb80-698887926a57","html_url":"https://github.com/mondeja/leptos-fluent","commit_stats":{"total_commits":196,"total_committers":5,"mean_commits":39.2,"dds":"0.020408163265306145","last_synced_commit":"4d0f4cc939fd3061dbd0d0b25ccf576ff07b3a48"},"previous_names":["mondeja/leptos-fluent"],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mondeja%2Fleptos-fluent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mondeja%2Fleptos-fluent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mondeja%2Fleptos-fluent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mondeja%2Fleptos-fluent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mondeja","download_url":"https://codeload.github.com/mondeja/leptos-fluent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247183204,"owners_count":20897539,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fluent","fluent-templates","framework","i18n","internationalization","leptos","leptos-fluent","reactive","translation"],"created_at":"2024-08-01T17:00:31.194Z","updated_at":"2025-12-26T02:56:39.093Z","avatar_url":"https://github.com/mondeja.png","language":"Rust","funding_links":[],"categories":["Components"],"sub_categories":["Unofficial"],"readme":"# leptos-fluent\n\n\u003c!-- This file has been autogenerated.\nTo update it, change the content of `leptos-fluent/src/lib.rs`\nand run `pre-commit run -a cargo-readme`\n--\u003e\n\n[![Crates.io](https://img.shields.io/crates/v/leptos-fluent?logo=rust)](https://crates.io/crates/leptos-fluent)\n[![License](https://img.shields.io/crates/l/leptos-fluent?logo=mit)](https://github.com/mondeja/leptos-fluent/blob/master/LICENSE)\n[![Tests](https://img.shields.io/github/actions/workflow/status/mondeja/leptos-fluent/ci.yml?label=tests\u0026logo=github)](https://github.com/mondeja/leptos-fluent/actions)\n[![Book](https://img.shields.io/github/actions/workflow/status/mondeja/leptos-fluent/.github%2Fworkflows%2Fci.yml?logo=github\u0026label=book)][book]\n[![docs.rs](https://img.shields.io/docsrs/leptos-fluent?logo=docs.rs)](https://docs.rs/leptos-fluent)\n[![Crates.io downloads](https://img.shields.io/crates/d/leptos-fluent)](https://crates.io/crates/leptos-fluent)\n[![Discord channel](https://img.shields.io/badge/discord-grey?logo=discord\u0026logoColor=white)](https://discord.com/channels/1031524867910148188/1251579884371705927)\n\nInternationalization framework for [Leptos] using [fluent-templates].\n\n## Installation\n\nAdd the following to your `Cargo.toml` file:\n\n```toml\n[dependencies]\nleptos-fluent = \"0.3\"\naxum = { version = \"0.8\", optional = true }\n\n[features]\nssr = [\n  \"leptos-fluent/ssr\",\n  \"leptos-fluent/axum\",  # actix and axum are supported\n  \"dep:axum\",\n]\n```\n\nIf you're using `cargo-leptos` to build your project, watch the\n_locales/_ folder with:\n\n```toml\n[package.metadata.leptos]\nwatch-additional-files = [\"locales\"]  # Relative to Cargo.toml\n```\n\n## Usage\n\nGiving the following directory structure:\n\n```plaintext\n.\n├── 📄 Cargo.toml\n├── 📁 locales\n│   ├── 📁 en\n│   │   └── 📄 main.ftl\n│   └── 📁 es\n│       └── 📄 main.ftl\n└── 📁 src\n    ├── 📄 main.rs\n    └── 📄 lib.rs\n```\n\n```ftl\n# locales/en/main.ftl\nhello-world = Hello, world!\nhello-args = Hello, { $arg1 } and { $arg2 }!\n```\n\n```ftl\n# locales/es/main.ftl\nhello-world = ¡Hola, mundo!\nhello-args = ¡Hola, { $arg1 } y { $arg2 }!\n```\n\nYou can use `leptos-fluent` as follows:\n\n```rust\nuse leptos::prelude::*;\nuse leptos_fluent::{I18n, leptos_fluent, move_tr, tr};\n\n#[component]\nfn I18nProvider(children: Children) -\u003e impl IntoView {\n    // See all options in the reference at\n    // https://mondeja.github.io/leptos-fluent/latest/leptos_fluent.html\n    leptos_fluent! {\n        children: children(),\n        // Path to the locales directory, relative to Cargo.toml.\n        locales: \"./locales\",\n        // Initial language when the user don't load any with\n        // the provided configuration.\n        default_language: \"en\",\n        // Check translations correctness in the specified files.\n        #[cfg(all(debug_assertions, not(feature = \"ssr\")))]\n        check_translations: true,\n\n        // Client side options\n        // -------------------\n        // Synchronize `\u003chtml lang=\"...\"\u003e` attribute with\n        // current active language.\n        sync_html_tag_lang: true,\n        // Synchronize `\u003chtml dir=\"...\"\u003e` attribute with `\"ltr\"`,\n        // `\"rtl\"` or `\"auto\"` depending on active language.\n        sync_html_tag_dir: true,\n        // Update language on URL parameter when changes.\n        set_language_to_url_param: true,\n        // Set initial language of user from URL in local storage.\n        initial_language_from_url_param_to_local_storage: true,\n        // Set initial language of user from URL in a cookie.\n        initial_language_from_url_param_to_cookie: true,\n        // Key used to get and set the current language of the\n        // user on local storage. By default is `\"lang\"`.\n        local_storage_key: \"language\",\n        // Get initial language from local storage if not found\n        // in an URL param.\n        initial_language_from_local_storage: true,\n        // Set the initial language of the user from\n        // local storage to a cookie.\n        initial_language_from_local_storage_to_cookie: true,\n        // Update language on local storage when changes.\n        set_language_to_local_storage: true,\n        // Get initial language from `navigator.languages`\n        // if not found in local storage.\n        initial_language_from_navigator: true,\n        // Set initial language of user from navigator to local storage.\n        initial_language_from_navigator_to_local_storage: true,\n        // Set initial language of user from navigator to a cookie.\n        initial_language_from_navigator_to_cookie: true,\n        // Attributes to set for language cookie.\n        // By default `\"\"`.\n        cookie_attrs: \"Secure; Path=/; Max-Age=600\",\n        // Update language on cookie when the language changes.\n        set_language_to_cookie: true,\n        // Set initial language from a cookie to local storage.\n        initial_language_from_cookie_to_local_storage: true,\n\n        // Server side options\n        // -------------------\n        // Set initial language from the `Accept-Language`\n        // header of the request.\n        initial_language_from_accept_language_header: true,\n\n        // Server and client side options\n        // ------------------------------\n        // Name of the cookie to get and set the current active\n        // language. By default `\"lf-lang\"`.\n        cookie_name: \"lang\",\n        // Set initial language from cookie.\n        initial_language_from_cookie: true,\n        // URL parameter to use setting the language in the URL.\n        // By default `\"lang\"`.\n        url_param: \"lang\",\n        // Set initial language of the user from an URL parameter.\n        initial_language_from_url_param: true,\n\n        // Desktop applications (feature `system`)\n        // ---------------------------------------\n        // Set initial language from the system locale.\n        initial_language_from_system: true,\n        // Set initial language of the user from\n        // the system locale to a data file.\n        initial_language_from_system_to_data_file: true,\n        // Get initial language from a data file.\n        initial_language_from_data_file: true,\n        // Key to use to name the data file. Should be unique per\n        // application. By default `\"leptos-fluent\"`.\n        data_file_key: \"my-app\",\n        // Set the language selected to a data file.\n        set_language_to_data_file: true,\n    }\n}\n\n#[component]\npub fn App() -\u003e impl IntoView {\n    view! {\n        \u003cI18nProvider\u003e\n            \u003cTranslatableComponent/\u003e\n            \u003cLanguageSelector/\u003e\n        \u003c/I18nProvider\u003e\n    }\n}\n\n#[component]\nfn TranslatableComponent() -\u003e impl IntoView {\n    // Use `tr!` and `move_tr!` macros to translate strings:\n    view! {\n        \u003cp\u003e\n            \u003cspan\u003e{move || tr!(\"hello-world\")}\u003c/span\u003e\n            \u003cspan\u003e{move_tr!(\"hello-args\", {\n                \"arg1\" =\u003e \"foo\",\n                \"arg2\" =\u003e \"bar\",\n            })}\u003c/span\u003e\n        \u003c/p\u003e\n    }\n\n    // The `tr!` macro must be inside a reactive context or the\n    // translation will not be updated on the fly when the language changes.\n}\n\n#[component]\nfn LanguageSelector() -\u003e impl IntoView {\n    // `expect_context::\u003cleptos_fluent::I18n\u003e()` to get the i18n context\n    // `i18n.languages` exposes a static array with the available languages\n    // `i18n.language.get()` to get the active language\n    // `i18n.language.set(lang)` to set the active language\n\n    let i18n = expect_context::\u003cI18n\u003e();\n\n    view! {\n        \u003cfieldset\u003e\n            {\n                move || i18n.languages.iter().map(|lang| {\n                    view! {\n                        \u003cdiv\u003e\n                            \u003cinput\n                                type=\"radio\"\n                                id=lang\n                                name=\"language\"\n                                value=lang\n                                checked=\u0026i18n.language.get() == lang\n                                on:click=move |_| i18n.language.set(lang)\n                            /\u003e\n                            \u003clabel for=lang\u003e{lang.name}\u003c/label\u003e\n                        \u003c/div\u003e\n                    }\n                }).collect::\u003cVec\u003c_\u003e\u003e()\n            }\n        \u003c/fieldset\u003e\n    }\n}\n```\n\n### Features\n\n- **Server Side Rendering**: `ssr`\n- **Actix Web integration**: `actix`\n- **Axum integration**: `axum`\n- **Nightly toolchain**: `nightly`\n- **Desktop applications**: `system`\n- **JSON languages file**: `json`\n- **YAML languages file**: `yaml`\n- **JSON5 languages file**: `json5`\n- **Tracing support**: `tracing`\n- **Debugging**: `debug`\n\n## Resources\n\n- [Book]\n- [Quickstart]\n- [Documentation]\n- [Examples]\n\n[leptos]: https://leptos.dev/\n[fluent-templates]: https://github.com/XAMPPRocky/fluent-templates\n[quickstart]: https://mondeja.github.io/leptos-fluent/latest/leptos_fluent.html\n[examples]: https://github.com/mondeja/leptos-fluent/tree/master/examples\n[book]: https://mondeja.github.io/leptos-fluent/latest/\n[documentation]: https://docs.rs/leptos-fluent\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmondeja%2Fleptos-fluent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmondeja%2Fleptos-fluent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmondeja%2Fleptos-fluent/lists"}