1 line
10 KiB
Markdown
Raw Normal View History

# nu_plugin_fluent\n\nA [Nushell](https://nushell.sh/) plugin for [Fluent](https://projectfluent.org/) internationalization (i18n) and localization (l10n) workflows.\n\n## Overview\n\nThis plugin provides powerful tools for managing multilingual applications using Mozilla's Fluent localization system. It enables you to parse, validate, localize, and manage Fluent Translation List (`.ftl`) files directly from Nushell.\n\n## Installing\n\nClone this repository\n\n> [!WARNING]\n> **nu_plugin_fluent** has dependencies to nushell source via local path in Cargo.toml\n> Nushell and plugins require to be **sync** with same **version**\n\nClone [Nushell](https://nushell.sh/) alongside this plugin or change dependencies in [Cargo.toml](Cargo.toml)\n\nThis plugin is also included as submodule in [nushell-plugins](https://repo.jesusperez.pro/jesus/nushell-plugins)\nas part of plugins collection for [Provisioning project](https://rlung.librecloud.online/jesus/provisioning)\n\nBuild from source\n\n```nushell\n> cd nu_plugin_fluent\n> cargo install --path .\n```\n\n### Nushell\n\nIn a [Nushell](https://nushell.sh/)\n\n```nushell\n> plugin add ~/.cargo/bin/nu_plugin_fluent\n```\n\n## Commands\n\n### `fluent-parse`\n\nParse a Fluent Translation List (`.ftl`) file and extract its message structure.\n\n```nushell\n> fluent-parse <file>\n```\n\n**Parameters:**\n\n- **file** `<path>`: FTL file to parse\n\n**Example:**\n\n```nushell\n> fluent-parse locales/en-US/main.ftl\n╭───────────────┬─────────────────────────────╮\n│ file │ locales/en-US/main.ftl │\n│ message_count │ 3 │\n│ messages │ [list of parsed messages] │\n╰───────────────┴─────────────────────────────╯\n```\n\n### `fluent-localize`\n\nLocalize a message using the Fluent translation system with hierarchical fallback support.\n\n```nushell\n> fluent-localize <message_id> <locale> [--files] [--bundle] [--args] [--fallback]\n```\n\n**Parameters:**\n\n- **message_id** `<string>`: Message ID to localize\n- **locale** `<string>`: Locale code (e.g., en-US, es-ES)\n\n**Flags:**\n\n- **--files** `-f` `<list>`: FTL files to load\n- **--bundle** `-b` `<record>`: Pre-loaded message bundle\n- **--args** `-a` `<record>`: Arguments for message interpolation\n- **--fallback** `-F`: Return message ID if translation not found\n\n**Examples:**\n\nBasic localization:\n\n```nushell\n> fluent-localize welcome-message en-US --files [locales/en-US/main.ftl]\n"Welcome to our application!"\n```\n\nWith arguments:\n\n```nushell\n> fluent-localize user-greeting en-US --files [locales/en-US/main.ftl] --args {name: "Alice"}\n"Hello, Alice! Welcome back."\n```\n\nWith fallback:\n\n```nushell\n> fluent-localize missing-message es-ES --files [locales/es-ES/main.ftl] --fallback\n"[[missing-message]]"\n```\n\n### `fluent-validate`\n\nValidate the syntax of a Fluent Translation List (`.ftl`) file.\n\n```nushell\n> fluent-validate <file>\n```\n\n**Parameters:**\n\n- **file** `<path>`: FTL file to validate\n\n**Example:**\n\n```nushell\n> fluent-validate locales/en-US/main.ftl\n╭────────┬─────────────────────────╮\n│ valid │ true │\n│ file │ locales/en-US/main.ftl │\n│ errors │ [] │\n╰────────┴─────────────────────────╯\n```\n\n### `fluent-extract`\n\nExtract message IDs from a Fluent Translation List (`.ftl`) file.\n\n```nushell\n> fluent-extract <file>\n```\n\n**Parameters:**\n\n- **file** `<path>`: FTL file to extract messages from\n\n**Example:**\n\n```nushell\n> fluent-extract locales/en-US/main.ftl\n╭───┬─────────────────╮\n│ 0 │ welcome-message │\n│ 1 │ user-greeting │\n│ 2 │ goodbye-message │\n