{"id":31618172,"url":"https://github.com/orhun/fluent-i18n","last_synced_at":"2026-04-07T19:31:46.961Z","repository":{"id":314752094,"uuid":"1054967581","full_name":"orhun/fluent-i18n","owner":"orhun","description":"A declarative and ergonomic internationalization for Rust using Fluent. Mirror of https://gitlab.archlinux.org/orhun/fluent-i18n","archived":false,"fork":false,"pushed_at":"2025-09-29T09:36:04.000Z","size":87,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-20T06:30:01.934Z","etag":null,"topics":["fluent","i10n","i18n","rust"],"latest_commit_sha":null,"homepage":"https://gitlab.archlinux.org/orhun/fluent-i18n","language":"Rust","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orhun.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSES/Apache-2.0.txt","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-11T15:19:48.000Z","updated_at":"2025-09-29T09:30:21.000Z","dependencies_parsed_at":"2025-09-14T15:54:44.557Z","dependency_job_id":"8550862f-2bb0-499d-9583-a3eec547a681","html_url":"https://github.com/orhun/fluent-i18n","commit_stats":null,"previous_names":["orhun/fluent-i18n"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/orhun/fluent-i18n","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhun%2Ffluent-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhun%2Ffluent-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhun%2Ffluent-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhun%2Ffluent-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orhun","download_url":"https://codeload.github.com/orhun/fluent-i18n/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhun%2Ffluent-i18n/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31526665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","i10n","i18n","rust"],"created_at":"2025-10-06T13:59:52.976Z","updated_at":"2026-04-07T19:31:46.955Z","avatar_url":"https://github.com/orhun.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fluent-i18n 🗣️🔥\n\n![docs.rs](https://img.shields.io/docsrs/fluent-i18n)\n![Crates.io MSRV](https://img.shields.io/crates/msrv/fluent-i18n)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![License: Apache-2.0](https://img.shields.io/badge/License-Apache-blue.svg)](https://opensource.org/license/apache-2-0)\n\n**A declarative and ergonomic internationalization for Rust using [Fluent]**.\n\n_Built on top of [`fluent-templates`] and inspired by the simplicity of [`rust-i18n`]_.\n\n## Features\n\n- Static file loading via [`i18n!()`] macro\n- Zero-boilerplate [`t!()`] macro for inline translations\n- Extensible argument system via [`ToFluentValue`] trait\n- Thread-local handling via [`set_locale()`] and [`get_locale()`]\n- Clean fallback locale management\n\n## Example\n\n```rust,ignore\nuse fluent_i18n::{i18n, t};\n\ni18n!(\"locales\", fallback = \"en-US\");\n\nprintln!(\"{}\", t!(\"greeting\"));\nprintln!(\"{}\", t!(\"welcome\", { \"name\" =\u003e \"Orhun\" }));\n```\n\nPlace your localization files in `locales/en-US/main.ftl`:\n\n```fluent\ngreeting = Hello, world!\nwelcome = Welcome, { $name }!\n```\n\nSee the [Fluent syntax] for more details about FTL files.\n\n## Usage\n\n### Installation\n\nAdd [`fluent-i18n`] to your `Cargo.toml`:\n\n```bash\ncargo add fluent-i18n\n```\n\n### Initialization\n\nAt the entry point of your application (e.g., `main.rs` or `lib.rs`), invoke the [`i18n!()`] macro to initialize the localization system:\n\n```rust,ignore\ni18n!(\"locales\");\n```\n\nOr with a fallback locale:\n\n```rust,ignore\ni18n!(\"locales\", fallback = \"en-US\");\n```\n\nThis will expose a static loader named `LOCALES` that will be used by the [`t!()`] macro for translations throughout your application.\n\nYou can also dynamically change the locale at runtime using the [`set_locale()`] function:\n\n```rust,ignore\nuse fluent_i18n::{set_locale, get_locale};\n\nset_locale(Some(\"tr\"))?;\n\nlet current_locale = get_locale()?;\n```\n\nRunning `set_locale(None)` will detect the system locale automatically.\n\n### Lookup\n\nTo look up a translation for a given key, use the [`t!()`] macro:\n\n```rust,ignore\nt!(\"greeting\");\n```\n\nWith parameters:\n\n```rust,ignore\nt!(\"count-items\", { \"count\" =\u003e 3 })\nt!(\"key\", { \"arg1\" =\u003e value1, \"arg2\" =\u003e value2 })\n```\n\nThe given parameters should be one of the [supported types](#supported-types).\n\n### Supported Types\n\nThe [`t!()`] macro interpolates values into the message using the [`ToFluentValue`] trait.\n\nThe following types implement the [`ToFluentValue`] trait:\n\n- `String`, `\u0026'static str`, `Cow\u003c'static, str\u003e`\n- Integer and float primitives (`usize`, `u32`, `i64`, etc.)\n- `Path`, `PathBuf`\n- `Option\u003cT\u003e` where `T` implements [`ToFluentValue`]\n\nYou can extend support for your own types by implementing this trait:\n\n```rust,ignore\nuse fluent_i18n::{FluentValue, ToFluentValue};\n\nimpl ToFluentValue for MyType {\n    fn to_fluent_value(\u0026self) -\u003e FluentValue\u003c'static\u003e {\n        FluentValue::from(self.to_string())\n    }\n}\n```\n\n### Locale Layout\n\nYou can organize `.ftl` files per locale, and shared files like `core.ftl` will be included in all locales.\n\n```text\nlocales/\n├── core.ftl\n├── en-US/\n│   └── main.ftl\n├── fr/\n│   └── main.ftl\n├── zh-CN/\n│   └── main.ftl\n└── zh-TW/\n    └── main.ftl\n```\n\nThe directory names should adhere to the [Unicode Language Identifier].\nIt also respects any `.gitignore` or `.ignore` files present.\n\nSee the [Fluent syntax] for more details about FTL files.\n\n### Testing\n\nIn tests, you can access the translations as usual without reinitialization:\n\n```rust,ignore\nuse fluent_i18n::t;\n\n#[test]\nfn test_translation() {\n    assert_eq!(t!(\"greeting\"), \"Hello, world!\");\n}\n```\n\n### Debugging\n\nWhen raw mode is enabled, translations will return the key itself instead of looking up the translation.\nThis is useful for debugging purposes to see which keys are being requested.\n\n```rust,ignore\nuse fluent_i18n::{t, set_raw_mode};\n\nset_raw_mode(true);\n\nlet raw_message = t!(\"some-translation-key\"); // \"some-translation-key\"\n```\n\nYou could also follow this workflow for translating missing strings:\n\n- Run the program and navigate to the area you want to test.\n- Enable raw mode with `set_raw_mode(true)`.\n- Look for untranslated output (the raw key will be shown instead of the translation).\n- Copy that key.\n- Search for it in the project.\n- Add the missing translation.\n\n### Security\n\nUnicode directional isolate characters (U+2068, U+2069) are disabled as default to prevent potential security issues like bidirectional text attacks. This also gives clean output without unexpected characters in translations.\n\nAlso, please note that this is only applicable for mixed-script languages such as Arabic, Hebrew, and Persian.\n\n## License \u0026 Contributions\n\nThis project can be used under the terms of the [Apache-2.0] or [MIT].\nContributions to this project, unless noted otherwise, are automatically licensed under the terms of both of those licenses.\n\n🦀 ノ( º \\_ º ノ) - _respect crables!_\n\nFeel free to open issues or PRs for improvements, bug fixes, or ideas!\n\n## Acknowledgements\n\n- [Project Fluent][Fluent]\n- [`fluent-templates`]\n- [`rust-i18n`]\n\nThis library was originally developed as part of the [ALPM project] and later extracted for general-purpose use.\n\n[`t!()`]: https://docs.rs/fluent-i18n/latest/fluent_i18n/macro.t.html\n[`i18n!()`]: https://docs.rs/fluent-i18n/latest/fluent_i18n/macro.i18n.html\n[`ToFluentValue`]: https://docs.rs/fluent-i18n/latest/fluent_i18n/trait.ToFluentValue.html\n[`set_locale()`]: https://docs.rs/fluent-i18n/latest/fluent_i18n/locale/fn.set_locale.html\n[`get_locale()`]: https://docs.rs/fluent-i18n/latest/fluent_i18n/locale/fn.get_locale.html\n[Fluent]: https://projectfluent.org\n[Fluent syntax]: https://projectfluent.org/fluent/guide/\n[`fluent-templates`]: https://docs.rs/fluent-templates\n[`rust-i18n`]: https://github.com/longbridge/rust-i18n\n[`fluent-i18n`]: https://crates.io/crates/fluent-i18n\n[ALPM project]: https://alpm.archlinux.page\n[Unicode Language Identifier]: https://docs.rs/unic-langid\n[Apache-2.0]: https://opensource.org/license/apache-2-0\n[MIT]: https://opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forhun%2Ffluent-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forhun%2Ffluent-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forhun%2Ffluent-i18n/lists"}