slang 4.2.0 slang: ^4.2.0 copied to clipboard
Localization / Internationalization (i18n) solution. Use JSON, YAML, CSV, or ARB files to create typesafe translations via source generation.
4.2.0 #
- feat: automatically sanitize invalid keys (e.g.
continue
,123
) (#257) - fix: do not override
locale
in L10n format definition
4.1.0 #
- feat: add
format
config to automatically format generated files (#184) - fix: correctly generate with
enum_name
andclass_name
different fromAppLocale
/Translations
(#254)
4.0.0 #
DateFormat, NumberFormat, and Lazy loading
Format translations with DateFormat
and NumberFormat
:
Hello {name}, today is {today: yMd}. You have {money: currency(symbol: '€')}.
On web, Deferred loading is used to reduce initial load time.
- feat: add
DateFormat
andNumberFormat
support (#112) - feat: add
lazy: true
config which is enabled by default (#135) - fix:
slang analyze
should not treat translations as unused if they are used in linked translations (#231) - fix:
slang analyze
should detect missing enums (#234) - fix: trim enum keys in compressed format while parsing (e.g.
"male, female": "..."
to"male,female": "..."
) (#247) - fix: compilation error on web when using large interfaces (#251)
- fix: correctly transform keys with modifiers when
key_case
is set (#253) - Breaking: Require Dart 3.3 and Flutter 3.19
- Breaking:
setLocale
,setLocaleRaw
, anduseDeviceLocale
returns a Future, use-Sync
suffix for synchronous calls - Breaking:
output_format
removed, always generates multiple files now - Breaking: deprecated functions in
LocaleSettings
(supportedLocales
,supportedLocalesRaw
) removed - Breaking: defining contexts (enums) is no longer allowed in
build.yaml
orslang.yaml
(deprecated in v3.19.0) - Breaking: enums specified in
context
are no longer transformed into pascal case keeping the original case
You can read the detailed migration guide here.
3.32.0 #
- feat: add syntax to escape linked translations (#248) @Fasust
- i18n: add Polish plural resolver (#245) @0rzech
- docs: broken Unicode CLDR link (#246) @0rzech
3.31.2 #
- fix: should match first language code if there are no matches by country code and at least one match by language code (#241) @Tienisto
3.31.1 #
- fix: "translation overrides" do not work with parameterized linked translations (#226) @Tienisto
- fix: linked translations should not be unused when running
dart run slang analyze
(#222) @Tienisto
3.31.0 #
- feat: add
dart run slang normalize
to normalize translations based on base locale @Tienisto - feat: add parameter type support (introduced 3.30.0) to ARB files (#214) @Tienisto
- feat: sort translation files for reproducible console output (#210) @poppingmoon
3.30.2 #
- fix: commented out translations should be declared as unused during
slang analyze
(#200) @nikaera - fix: should use interpolation for strings with a single parameter (#207) @Tienisto
- fix: encode csv files correctly (#202) @nikaera
3.30.1 #
- fix: when applying translations with
dart run slang apply
, only modifiers from the base locale should be used (#192)
3.30.0 #
- feat: add parameter types (e.g.
Hello {name: String}, you are {age: int} years old
); isObject
by default @Tienisto - fix: handle nested interfaces (#191) @Tienisto
- refactor: move code to src folder @Tienisto
3.29.0 #
- feat:
dart run slang analyze
supports csv files (#185) @nikaera - feat: also add linter and coverage ignore to part files (#188) @cmenkemeller
- fix: generate base translations as fallback when using context enums where some enum values are missing (#182) @Tienisto
- fix: generate correct
part of
directive when using a custom dart file extension (#187) @cmenkemeller
3.28.0 #
- feat: add
fallback_strategy: base_locale_empty_string
to also treat empty strings as missing translations (#180) - fix: special case where linked translations had invalid parenthesis (#181)
3.27.0 #
- feat: add support for ARB files (#179)
3.26.2 #
- fix: should not escape special characters when parsed via the "Translation Overrides" feature (#177)
3.26.1 #
- fix: generate correct compatibility typedef for
Translations
class (#176)
3.26.0 #
- feat: base translation class is named
Translations
so thatTranslations.of(context)
returns the same type (#169) - feat: the name
Translations
can be configured viaclass_name
(@bjernie, #174) - feat: add
statistics
configuration (similar totimestamp
) to hide statistics in generated file
3.25.0 #
- feat: add
dart run slang clean
to remove unused translations after runningslang analyze
(#141) - feat: add
--exit-if-changed
toslang analyze
to fail CI if there are missing / unused translations (#141) - fix: code generator should not crash if context is not included in i18n (#165)
- fix: should not generate
contextBuilder
andnBuilder
parameter in rich text if not needed (#168)
3.24.0 #
- feat:
slang edit add
respects order in base locale (@adil192) - feat:
slang edit add
works without a specified locale, it will add the string to all locales - feat: use
WidgetsBinding.instance.platformDispatcher
instead ofPlatformDispatcher.instance
infindDeviceLocale
implementation - fix: correctly obfuscate line breaks and single quotes
3.23.0 #
- feat: support multiple
TranslationProvider
at the same time when using multiple packages - fix: trailing slash in config does not work with
build_runner
- i18n: Swedish plural resolver improvement (by @lohnn)
3.21.0 #
- feat: add input directory as comment to generated files
- fix: migrate away from deprecated
WidgetsBinding.instance.window
infindDeviceLocale
implementation - fix: handle empty maps in
_missing_translations
in yaml format (by @adil192)
3.19.0 #
- feat: add enum value inference (no need to specify
enum
in the config anymore) - feat: add
slang edit copy
to copy translations - feat: namespaces may contain underscores if at least one file of same directory uses locale from directory name
- DEPRECATED: Use explicit
context
modifier instead of relying on the config file (see migration guide)
3.18.1 #
- chore: add logo
3.18.0 #
- feat: add
slang edit
tomove
ordelete
translations over all locales - fix: avoid infinite loop of symlinks
3.17.0 #
- fix: setLocale does not work when Locale enum is from two packages (by @fzyzcjy)
- fix:
slang outdated
should skip missing translations instead of throwing an error
3.16.2 #
- fix: handle dynamic keys when
fallback_strategy: base_locale
is used
3.16.1 #
- fix: handle interpolation when obfuscation is enabled
3.16.0 #
- feat: add
obfuscation
config to obfuscate translation strings
3.15.1 #
- fix:
slang analyze
with--full
should find invocations written in multiple lines
3.15.0 #
- feat: add
OUTDATED
modifier to flag translations as outdated (slang analyze
will treat them as missing) - feat: run
flutter pub run slang outdated my.key.path
to flag translations as outdated - feat:
slang apply
prefers modifiers from base locale over secondary locales
3.14.0 #
- feat:
LocaleSettings.useDeviceLocale
listens to device locale changes - feat:
flutter pub run slang apply
only applies changed locales by default - fix: locale selection with script code (e.g.
zh-Hant-TW
useszh-TW
instead ofzh-HK
)
3.13.0 #
- feat: generated files from
analyze
andapply
have\n
at the end of the file
3.12.0 #
- feat: mixins generated by the interface feature now have
==
andhashCode
overrides - feat:
flutter pub run slang apply
now respects the order in the base locale instead of simply add the new translations to the end - feat:
flutter pub run slang analyze
now have--split-missing
and--split-unused
(in addition to--split
) so only one of both can be a single file
3.11.1 #
- fix: missing unused translations in secondary locales
3.11.0 #
- feat: add
(ignoreMissing)
and(ignoreUnused)
modifiers which changes the behaviour offlutter pub run slang analyze
3.10.0 #
- feat: there is now a default plural resolver so the app keeps working in production when you forgot to define one, you will only see a warning in the log
- fix:
key_map_case
should work with(map)
modifier
3.9.0 #
- feat: improve interface attribute inference algorithm
- feat: generate to
lib/gen/<filename>
in Flutter environment by default if input is outside oflib/
and no output directory is given
3.8.0 #
- feat: add
(interface=<Interface>)
and(singleInterface=<Interface>)
modifiers, a new approach to configure interfaces without touching the config file - feat: add
AppLocaleUtils.supportedLocales
andAppLocaleUtils.supportedLocalesRaw
, this API works inlocale_handling: false
- fix: possible class name conflict for objects inside lists
- DEPRECATED:
LocaleSettings.supportedLocales
andLocaleSettings.supportedLocalesRaw
3.7.0 #
- feat: official web support
3.6.0 #
- feat: RichText supports links inside default translation
- feat:
flutter pub run slang watch
works recursively and does not crash on error
3.5.0 #
- feat: csv decoding now support both
CRLF
andLF
,"
and'
- fix:
LocaleSettings.setPluralResolver
should not throw an assertion error - fix:
flutter pub run slang migrate
should also work without:
in command
3.4.0 #
- feat: add
--locale=<locale>
argument toflutter pub run slang apply
to only apply a specific locale - BREAKING (TOOL):
--flat
argument forflutter pub run slang analyze
andapply
is no longer available
3.3.1 #
- fix: when namespaces are used, consider more directories (not only parent) for locale detection (e.g.
assets/i18n/en-US/pages/home.json
)
3.3.0 #
- feat:
flutter pub run slang analyze
now also checks unused translations (on top of missing translations) - docs: prefer
slang analyze
overslang:analyze
(and for all other commands); both styles are supported however
3.2.0 #
- feat: add command
flutter pub run slang:apply
to add translations from theslang:analyze
result - fix: handle
isFlatMap
parameter when overriding translations correctly - fix: update arb migration tool to respect new modifier syntax
3.1.0 #
- feat: add command
flutter pub run slang:analyze
to report missing translations
3.0.0 #
Translation Overrides and Enhanced Modifiers
- feat: it is now possible to override translations via
LocaleSettings.overrideTranslations
(checkout updated README) - feat: there is a new modifier syntax which allows for multiple modifiers e.g.
myKey(plural, rich)
- feat: improve file scan (now only checks top-level directory for any config files)
- Breaking: default plural parameter is now
n
; you can revert this by settingpluralization
/default_parameter: count
- Breaking: custom plural/context parameter must follow syntax
apples(param=appleCount)
All breaking changes will result in a compile-time error, so don't worry for "hidden" bugs :)
You can read the detailed migration guide here.
2.8.0 #
- feat: add
AppLocaleUtils.parseLocaleParts
- fix:
LocaleSettings.useDeviceLocale
now does not complain of weird locales on Linux - fix: rich text now handles all characters
- fix: rich text properly applies param_case
- fix: empty nodes are rendered as classes instead of claiming them as plurals
2.7.0 #
- feat: ignore empty plural / context nodes when
fallback_strategy: base_locale
is used - feat: add
coverage:ignore-file
to generated file and ignore every lint
2.6.2 #
- feat: add Russian plural resolver (thanks to @LuckyWins)
- fix: parse rich text with interpolation
braces
anddouble_braces
correctly
2.6.1 #
- fix: remove
const
if rich text has links
2.6.0 #
- feat: render context enum values as is, instead of forcing to camel case
- feat: add additional lint ignores to generated file
- fix: generate correct ordinal (plural) call
- fix: handle rich texts containing linked translations
2.5.0 #
- feat: add extension method shorthand (e.g.
context.tr.someKey.anotherKey
) - feat: add
LocaleSettings.getLocaleStream
to keep track of every locale change - feat: return more specific
TextSpan
instead ofInlineSpan
for rich texts
2.4.1 #
- fix: do not export
package:flutter/widgets.dart
2.4.0 #
- feat: allow external enums for context feature (add
generate_enum
andimports
config) - feat: add default context parameter name (
default_parameter
) - feat: add export statement in generated file to avoid imports of extension methods
2.3.1 #
- fix: add missing fallback for flat map if configured
2.3.0 #
- feat: use tight version for
slang_flutter
andslang_build_runner
- fix: throw error if base locale not found
- fix:
TranslationProvider
should use current locale - fix: use more strict locale regex to avoid false-positives when detecting locale of directory name
2.2.0 #
- feat: locale can be moved from file name to directory name (e.g.
i18n/fr/page1_fr.i18n.json
toi18n/fr/page1.i18n.json
)
2.1.0 #
- feat: add
slang.yaml
support which has less boilerplate thanbuild.yaml
- fix: move internal
build.yaml
to correct package
2.0.0 #
Transition to a federated package structure
- Breaking: rebranding to
slang
- Breaking: add
slang_build_runner
,slang_flutter
depending on your use case - Breaking: remove
output_file_pattern
(was deprecated) - feat: dart-only support (
flutter_integration: false
) - feat: multiple package support
- feat: RichText support
Thanks to @fzyzcjy.
You can read the detailed migration guide here.