i18n
4.2.6, released 6 months ago by muha.dev
Simple i18n solution using YAML files to generate compile-safe Dart translation classes.
What it does
Allows writing messages into YAML files and uses build_runner to generate convenient, compile-safe Dart classes with support for parameters and pluralization.
AI-written summary of version 4.2.6, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want compile-time safety for your localization keys
- You prefer calling methods instead of arbitrary strings for translations
- You already use build_runner in your project
Skip it when
- You prefer zero code generation and dynamic runtime loading
- You want a fully-featured localization suite without writing custom plurals for unsupported languages
Strengths
- Compile-time safety and autocomplete support
- Leverages standard Dart string interpolation
- Supports pluralization and cardinal/ordinal rules
Weaknesses
- Requires build_runner and code generation steps
- Built-in plural rules are currently limited to English and Czech unless custom rules are added
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 7
Add build_runner as a dev_dependency and i18n as a dependency, then run the build_runner watch command.
Messages m = Messages();
print(m.users.welcome('World'));Alternatives
Packages that do the same job and could replace i18n.
- intl
Official internationalization package with extensive locale and date/number formatting support.
93Compare - easy_localization
Supports easy translation loading from JSON, YAML, CSV files without strict code generation.
64Compare - slang
Another strong type-safe localization package using code generation with rich features.
90Compare
Works with
Packages commonly used together with i18n: ones it builds on, ones built on it, and its own family.
- yamli18n depends on itA Dart library for parsing YAML documents into Dart data structures.
- pub_semveri18n depends on itVersions and version constraints implementing pub's versioning policy.
- globi18n depends on itA file and directory globbing library that supports Bash-style path matching and listing.
- dart_stylei18n depends on itProvides an API and CLI to format Dart source code automatically.
- buildi18n depends on itPackage for authoring build_runner compatible code generators.
- build_configi18n depends on itFormat definition and support for parsing build.yaml configuration.
- quick_logi18n depends on itA configurable Dart logger for libraries and apps
- build_runnerUsed togetherA build system for Dart code generation and modular compilation.