{"id":13411703,"url":"https://github.com/rkh/nii","last_synced_at":"2025-09-29T00:33:18.850Z","repository":{"id":66032257,"uuid":"344186442","full_name":"rkh/nii","owner":"rkh","description":"Modern internationalization and localization solution for Ruby","archived":false,"fork":false,"pushed_at":"2021-10-20T16:41:29.000Z","size":34003,"stargazers_count":23,"open_issues_count":13,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-13T16:50:58.128Z","etag":null,"topics":["globalization","i18n","internationalization","l10n","localization","ruby","ruby-on-rails","sinatra","translation"],"latest_commit_sha":null,"homepage":"https://nii.dev","language":"Ruby","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/rkh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2021-03-03T16:13:21.000Z","updated_at":"2024-12-11T13:35:43.000Z","dependencies_parsed_at":"2023-04-03T11:33:25.979Z","dependency_job_id":null,"html_url":"https://github.com/rkh/nii","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkh%2Fnii","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkh%2Fnii/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkh%2Fnii/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkh%2Fnii/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rkh","download_url":"https://codeload.github.com/rkh/nii/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234575246,"owners_count":18854926,"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":["globalization","i18n","internationalization","l10n","localization","ruby","ruby-on-rails","sinatra","translation"],"created_at":"2024-07-30T20:01:15.979Z","updated_at":"2025-09-29T00:33:10.419Z","avatar_url":"https://github.com/rkh.png","language":"Ruby","readme":"\u003c!-- This file has been generated. Source: src/README.md.erb --\u003e\n\n# Nii\n\n[![Test](https://github.com/rkh/nii/actions/workflows/ci.yml/badge.svg)](https://github.com/rkh/nii/actions/workflows/ci.yml)\n\nNii is an **internationalization** (i18n) and **localization** (l10n) solution for Ruby. It is **modular**, **comprehensive**, **fast**, and built on top of **modern standards** and best practices.\n\nWith Nii, you can **[manage translations](#translation-management)**, **[localize any Ruby object](#object-localization)**, all with an easy to use, powerful **[configuration setup](#advanced-setups)**. It includes out of the box support for **[233 languages](docs/languages.md)**, with **1531 language variants**.\n\n## Translation Management\n\nNii manages your application's translated content.\nSimilar solutions include [Ruby I18n](https://github.com/ruby-i18n/i18n), [R18n](https://github.com/r18n/r18n), [gettext](https://ruby-gettext.github.io/), and [FastGettext](https://github.com/grosser/fast_gettext).\n\n### Example\n\n`locales/en/example.ftl` (localization for [English](docs/languages/en.md), using [Fluent](docs/formats/fluent.md)):\n\n``` fluent\nhello-world = Hello World!\n\ngreeting =\n  { NOW() -\u003e \n    [morning]   Good morning, {$name}!\n    [afternoon] Good afternoon, {$name}!\n    [night]     Good night, {$name}!\n   *[other]     Good day to you!\n  }\n```\n\n`example.rb`:\n\n``` ruby\n# Load translations from \"locales\" directory\nconfig = Nii[\"locales\", namespace: :example]\n\n# Create a new context for Englisch\ncontext = Nii::Context.new(:en, config)\ncontext.render \"hello-world\"                # =\u003e \"Hello World!\"\ncontext.render :greeting, { name: \"Maria\" } # =\u003e \"Good morning, Maria!\" (depending on time of day)\n```\n\n### Notable Features\n\n* Load translations from the local file system. Supports a range of directory structures and naming conventions.\n* Load translations from an inline definition.\n* [Load translations from a database](nii-sql). A wide range of databases is supported.\n  Nii can also reuse an existing Active Record or Sequel connection or connection pool.\n* Load translations from multiple sources.\n* Translations are grouped in namespaces for content isolation.\n* Support for reusable terms and translation attributes.\n* Load translations from a custom backend.\n* Support for a wide variety of [file formats](docs/formats.md), including [Fluent](docs/formats/fluent.md),\n  [Gettext](docs/formats/gettext.md), [YAML](docs/formats/yaml.md),\n  [JSON](docs/formats/json.md), [TOML](docs/formats/toml.md), [XLIFF](docs/formats/xliff.md),\n  [Java/Mozilla properties files](docs/formats/properties.md) and more.\n* Ability to convert between file formats. Useful if developers work with different formats than translators, or to import translations.\n* Automatically load new translations and reload updated translations in development mode. It will only reload updated files.\n* Advanced support for various [grammatical rules](docs/grammar.md), including plural categories (cardinal/ordinal/ranges,\n  full support for all CLDR conditions), cases, genders, definiteness, T-V distinction (formal vs informal pronouns).\n* Directly load translations from Ruby I18n or R18n into Nii.\n* Use Nii as a [backend for Ruby I18n](nii-i18n).\n* Built-in support for [HTML formatting](docs/html.md), sanitizing, and escaping (compatible with Active Support).\n* Support for positional and named arguments, which can be provided ad hoc and/or predefined.\n* Comes with a library of [template functions](docs/functions.md) for more flexible translations.\n* Script and directionality aware string constructions, with automatic support for bidirectional text, with embedded UTF-8 markers or HTML tags.\n* Differentiates between language inheritance and fallbacks, to avoid mixed language content.\n\n## Object Localization\n\nNii converts various Ruby objects into human readable, well formatted, localized strings. Similar solutions include [TwitterCldr](https://github.com/twitter/twitter-cldr-rb) and [Active Support](https://guides.rubyonrails.org/active_support_core_extensions.html).\n\n### Example\n\n``` ruby\n# Create a context for English\nnii = Nii::Context.new \"en\" # =\u003e #\u003cNii::Context:en-US\u003e\n\n# Formatting various objects\nnii.format 9.99, style: :currency            # =\u003e \"$9.99\"\nnii.format Nii::Territory[\"US\"]              # =\u003e \"United States\"\nnii.format [\"de\", \"fr\", \"it\"], as: :language # =\u003e \"German, French, and Italian\"\n\n# Spelling out numbers (and other objects)\nnii.spellout 2020                 # =\u003e \"two thousand twenty\"\nnii.spellout 2020, rule: :year    # =\u003e \"twenty twenty\"\nnii.spellout 115,  rule: :ordinal # =\u003e \"one hundred fifteenth\"\n\n# Proper HTML interpolation\nvalues = [\"\u003cfoo\u003e\", \"\u003cbar\u003e\"]\nresult = nii.format(values) { nii.html \"\u003cb\u003e?\u003c/b\u003e\", _1 }\nresult            # =\u003e \"\u003cb\u003e\u0026lt;foo\u0026gt;\u003c/b\u003e and \u003cb\u003e\u0026lt;bar\u0026gt;\u003c/b\u003e\"\nresult.html_safe? # =\u003e true\n\n# Using RubyMoney\nrequire \"money\"\nprice = Money.eur 15_00\nnii.format   price # =\u003e \"€15.00\"\nnii.spellout price # =\u003e \"fifteen euros\"\n```\n\n### Notable Features\n\n* Format numeric values with smart defaults and a high level of customizability.\n  * Localized symbols, delimiters, and separators.\n  * Localized delimiter and separator position (numbers in Indian English and other languages are formatted correctly).\n  * Fine-grained control over precision, rounding, sign display, etc.\n  * Support for Unicode style decimal formatting patterns (subset of Excel/Google decimal patterns).\n  * Support for Unicode Rule Based Number Formats (RBNF).\n  * Support for multiple formatting styles (default, decimal, currency, precent, or unit).\n  * ECMAScript API compatibility (you can use the same formatting rules server-side that you use in your client-side JavaScript code).\n  * Support for various numbering systems, including decimal systems (Latin, Arab, etc), and non-decimal systems (like Traditional Chinese Numerals).\n    You can directly specify a different numbering system, or have Nii pick the appropriate default, native, traditional, or financial numbering system\n    for the given locale.\n* Format money objects, compatible with [RubyMoney](http://rubymoney.github.io/money/), [shopify-money](http://shopify.github.io/money/), custom Money classes, as well as directly from numeric values (if you provide a currency or style option).\n  * Localized currency symbols and names (AS$ vs $).\n  * Localized currency position and spacing rules.\n  * Handles unknown currencies well (example: falls back to RubyMoney currency information for BTC, which is not included in the CLDR).\n  * Ability to round to valid cash amount (for currencies that don't have a single cent/fraction coin or bill).\n* Format Arrays as lists.\n  * Support different styles (and/or/unit, each also as short or narrow).\n  * Provide formatting options applied to all elements.\n  * Dynamically format elements in the list (useful for injecting markup).\n  * Support complex localization rules (languages like Spanish, Hebrew, and Luxembourgish use different words or spellings for \"and\" depending on the list elements).\n  * Properly handle bidirectional content (for example, Arabic words listed in English).\n* Format Hashes as localized key-value list.\n* Built-in formatters for popular gems.\n  * Active Support: Duration, TimeZone, TimeWithZone.\n  * Concurrent Ruby: Array, Hash, Map, Set, Tuple.\n  * TZinfo: Timezone, Timestamp, Country.\n  * Nii: Calendar, Date, DayPeriod, Locale, NumberingSystem, Territory, Timezone, Timezone::Meta, Units (as part of nii-units).\n  * RubyMoney, shopify-money.\n* Format Date, Time, and DateTime.\n  * Support alternative calendars (anything besides Gregorian requires nii-calendars gem).\n  * Determine localized day period (\"afternoon\" has a different meaning based on language and location).\n* Format strings and symbols.\n  * Turn identifiers into localized names for calendar systems, collation algorithms, currencies, day periods, keys, languages, measurement systems,\n    countries and territories, scripts, units, and variants.\n  * Format strings as if they were numbers.\n* Spell out numbers and money objects as words and phrases.\n  * Supports multiple spelling rules per language to handle cardinal and ordinal numbers, as well as cases, genders and other grammatical aspects.\n* Partially format and re-format values (useful for setting default formatting rules for variable passed to dynamic translations).\n* Add custom formatters for your own Ruby objects.\n\n## Content Negotiation\n\n… *todo* …\n\n### Example\n\n… *todo* …\n\n### Notable Features\n\n… *todo* …\n\n## Advanced Setups\n\n… *todo* …\n\n### Example\n\n… *todo* …\n\n### Notable Features\n\n… *todo* …\n\n## Modern Internals\n\n… *todo* …\n\n\n## License\n\nNii is licensed under an [MIT License](LICENSE).\nIt also includes modified versions of the CLDR data files, which are licensed under a [Unicode license](nii-core/data/LICENSE).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frkh%2Fnii","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frkh%2Fnii","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frkh%2Fnii/lists"}