slang
4.19.2, released 2 months ago by tienisto.com
Type-safe i18n solution generating Dart translation classes from JSON, YAML, CSV, or ARB files
What it does
Generates compile-time type-safe Dart classes from localization source files (JSON, YAML, CSV, ARB). Eliminates string typos and missing parameter bugs by exposing translations as native method calls and getters. Includes a dedicated CLI for managing, analyzing, normalizing, and migrating translations.
AI-written summary of version 4.19.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want compile-time type safety for translation keys and parameterized strings
- You prefer structured translation formats like JSON, YAML, or CSV over standard ARB files
- You need rich features like pluralization, dynamic keys, linked translations, and regional fallbacks
Skip it when
- You want to avoid code generation entirely and load raw translation strings at runtime
- You strictly want standard Flutter ARB workflows without external tool dependencies
Strengths
- Fast execution via direct Dart method calls without runtime string parsing
- Rich feature set including plurals, context enums, interfaces, linked translations, and RichText support
- Comprehensive CLI tooling for migration, analyzing unused/missing keys, and normalizing files
Weaknesses
- Requires code generation steps whenever translation files change
- Typically requires a companion package (slang_flutter) for idiomatic Flutter integration
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 5
Requires creating translation files (e.g., in lib/i18n), running `dart run slang` to generate code, and configuring iOS CFBundleLocalizations in Info.plist.
import 'package:my_app/i18n/strings.g.dart';
void main() {
// Accessing generated type-safe translations
final title = t.mainScreen.title;
final greeting = t.greet(name: 'Tom');
}Alternatives
Packages that do the same job and could replace slang.
- easy_localization
Provides JSON/YAML/CSV localization without mandatory code generation steps
64Compare
Works with
Packages commonly used together with slang: ones it builds on, ones built on it, and its own family.
- yamlslang depends on itA Dart library for parsing YAML documents into Dart data structures.
- watcherslang depends on itMonitors file system changes and notifies when files are added, removed, or modified.
- intlslang depends on itA Dart library for internationalization and localization, providing message translation, plural/gender handling, and date/number formatting.
- serial_csvslang depends on itHigh-performance CSV encoder/decoder preserving types and nullability
- slang_flutterBuilt on slangFlutter support for the slang localization library.
- slang_build_runnerBuilt on slangbuild_runner integration for slang translation generation
- shadcn_uiBuilt on slangFlutter port of the shadcn/ui design system with customizable components.
- shadBuilt on slangA Flutter port of shadcn/ui with 40+ components and no Material dependency.