Skip to content

v1.0.0

Choose a tag to compare

@github-actions github-actions released this 15 Oct 12:26
· 14 commits to main since this release
8a76405

First stable release. See the README for full documentation.

Upgrading from 0.x

These changes can affect existing projects:

  • Norwegian users get Norwegian. Languages are now matched through the culture and its parents, plus aliases, instead of TwoLetterISOLanguageName. nb-NO, nb, nn-NO and nn now use no.json; before, they silently got the fallback language. Region files such as pt-br.json also match. Configure extra aliases with I18NLanguageAliases (e.g. nb=no;nn=no).
  • Two-form plurals are fixed. "car | cars" now follows vue-i18n: car(1) returns "car", every other count returns "cars". Before, car(1) returned "cars". Three-form messages are unchanged; negative counts now use the absolute value.
  • LanguageStrings falls back per key. GetString/GetStringOrNull return the fallback language's text when the current language lacks a key, like Language already did.
  • Linked messages are resolved. Text such as @:common.save is replaced with the target message in all generated APIs.
  • New warnings may appear on existing translation files: I18N007 (key missing from a language), I18N008 (key not in the fallback language), I18N009 (invalid language alias), I18N010 (invalid linked message). They are reported on the JSON files, so set their severity in a .globalconfig or with NoWarn, not in .editorconfig sections.
  • New generated types LocalizedLanguage, LocalizedLanguageGroups and the internal LanguageTranslations are added next to Language. If your project already has types with these names in the generated namespace, rename them or set GeneratedNamespace.

New features

  • Explicit culture: new LocalizedLanguage(culture).message.hello, LanguageStrings.GetString(key, culture), for background jobs, emails and tests without changing the thread culture.
  • Format specifiers in placeholders: {date:d}, {amount:N2}, formatted with the culture. These are .NET-only; vue-i18n does not understand them.
  • vue-i18n message syntax: linked messages (@:key, @:{'key'}, @.lower:, @.upper:, @.capitalize:), literals ({'|'}, {'@'}, with escapes), list placeholders ({0}).
  • Listings: LanguageStrings.FallbackLanguage, Languages, Keys, GetAllStrings(...).
  • Formatting by key: LanguageStrings.Format(key, args) with the same parameter order as the generated Language member.
  • IStringLocalizer support: when the project references Microsoft.Extensions.Localization.Abstractions, LanguageStringLocalizer and LanguageStringLocalizerFactory are generated, so IStringLocalizer<T> and validation messages can use the translation files.
  • The package's release notes on nuget.org now link to the GitHub release.

Pull requests

  • feat: warn about keys missing from a language in #11
  • feat: match cultures to translation files with language aliases in #13
  • feat: explicit culture API and format specifiers in #14
  • feat: vue-i18n message syntax and plural rules in #15
  • feat: list languages and keys, format by key, IStringLocalizer support in #16
  • chore: link package release notes to the GitHub release in #17

Full Changelog: v0.2.0...v1.0.0