Skip to content
pubscout

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

WASM-readyRock solid
$ flutter pub add slang
Source repository

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.

Works with

Packages commonly used together with slang: ones it builds on, ones built on it, and its own family.