Skip to content

Releases: bcc-code/bcc-i18n-source-generation

v1.2.0

Choose a tag to compare

@github-actions github-actions released this 15 Oct 13:15
ebb8a3a

The generated types now default to the project's RootNamespace. See the manual and the README.

Changes

  • Breaking: generated types default to RootNamespace. When GeneratedNamespace is not set, the types are generated in the project's RootNamespace. In 1.1.0 and earlier they were generated in the global namespace with the NuGet package, because the props file read RootNamespace before the project set it. Code that refers to the types from another namespace needs using <RootNamespace>;, or set GeneratedNamespace to keep a specific namespace. Projects that set GeneratedNamespace are unaffected.
  • Invalid characters in the default namespace are replaced. The SDK default RootNamespace is the project name, so a project named My-App gets the namespace My_App. An explicit GeneratedNamespace is used as written.
  • User manual. The documentation is now a manual with tutorials, how-to guides, reference and explanation pages.

Pull requests

  • docs: add user manual (Diátaxis) in #18
  • fix: default the generated namespace to RootNamespace in #19

Full Changelog: v1.1.0...v1.2.0

v1.1.0

Choose a tag to compare

@github-actions github-actions released this 15 Oct 12:47
da24b08

The generator no longer depends on System.Text.Json. See the README for documentation.

Changes

  • No System.Text.Json dependency. Translation files are read by a small built-in JSON reader. The package now contains only the generator, the props files and the README. Earlier packages shipped System.Text.Json with only some of its dependencies, which could fail to load in compilers hosted on .NET Framework (Visual Studio).
  • Diagnostics point at the error. I18N001 (invalid JSON) is reported at the exact position, with line and column in the message. I18N003 (unsupported value) is reported on the property name.
  • Lone surrogates are reported. A lone surrogate in a translation file, escaped ("\uD83D") or raw, now gives I18N001. Before, an escaped one crashed the generator.
  • Fix: line separators and control characters in values. U+0085, U+2028, U+2029 and other control characters are now escaped in generated code. In 1.0.0, a U+2028 in a value broke the build with CS1010.

The JSON rules are unchanged: no comments, no trailing commas, a single root object, depth up to 64. I18N001 messages have new wording.

Pull requests

  • Replace System.Text.Json with a built-in JSON reader in #12

Full Changelog: v1.0.0...v1.1.0

v1.0.0

Choose a tag to compare

@github-actions github-actions released this 15 Oct 12:26
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

v0.2.0

Choose a tag to compare

@github-actions github-actions released this 15 Oct 10:49
a1926ac

What's Changed

New Contributors

Full Changelog: v0.1.0...v0.2.0