slang  by slang-i18n

Type-safe i18n solution for Dart and Flutter apps

Created 5 years ago
559 stars

Top 57.4% on SourcePulse

GitHubView on GitHub
Project Summary

slang is a Dart and Flutter library for type-safe internationalization (i18n). It simplifies the process of managing translations, ensuring type safety and compile-time checks for your localized strings, benefiting developers building multi-language applications.

How It Works

slang leverages Dart's static typing and code generation to create type-safe accessors for your translation keys. It parses translation files (e.g., .arb or .json) and generates Dart code that maps directly to your localized strings, including support for pluralization and parameters. This approach eliminates runtime errors associated with missing keys or incorrect parameter types.

Quick Start & Requirements

  • Install via dart pub add slang or flutter pub add slang.
  • Requires Dart SDK 3.0+ or Flutter 3.10+.
  • Run dart run slang or flutter pub run slang to generate code.
  • Official documentation: https://slang.dev/docs/getting-started/

Highlighted Details

  • Supports multiple translation file formats (.arb, .json, .yaml).
  • Generates type-safe enums for translation keys.
  • Handles pluralization, gender, and named parameters.
  • Offers features like translation validation and diffing.
  • Integrates with Flutter's Localizations system.

Maintenance & Community

Licensing & Compatibility

  • Licensed under the MIT License.
  • Permissive license allows for commercial use and integration with closed-source projects.

Limitations & Caveats

The library is primarily focused on Dart and Flutter projects; cross-platform support outside this ecosystem is not a stated goal. While robust, complex translation structures might require careful organization to maintain optimal generated code readability.

Health Check
Last Commit

1 week ago

Responsiveness

1 day

Pull Requests (30d)
1
Issues (30d)
0
Star History
6 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.