Skip to content
pubscout

language_code

0.7.1, released 6 months ago by lamnhan.dev

Get current device language code and locale with full ISO 639-1 and ISO 639-2 dictionaries.

WASM-ready
$ flutter pub add language_code
Source repository

What it does

Provides current device language codes and localized names (English and native). Allows converting between Locales and ISO language codes, resolving matching variants, and overriding locales during unit testing.

AI-written summary of version 0.7.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to detect the current device language or locale.
  • You want a complete catalog of ISO 639-1 and ISO 639-2 codes with native names.
  • You need robust locale matching and fallback strategies in tests.

Skip it when

  • You are building a complex multi-language translation and pluralization management system.
  • You only need standard Flutter Localization without extra language metadata.

Strengths

  • Includes almost all ISO 639 language codes with English and native names.
  • Provides test-friendly overrides for device language and locale.
  • Robust fallback and resolution logic for complex locale variants.

Weaknesses

  • Throws a StateError if a lookup fails unless an orElse is specified.
  • Relies on automatic scrapers which may occasionally require community updates for new language codes.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
final languageCode = LanguageCode.code;
final locale = LanguageCode.locale;

Alternatives

Packages that do the same job and could replace language_code.

  • intl

    If you need comprehensive internationalization, date/number formatting, and message translation support.

  • devicelocale

    If you only need raw device locale retrieval without the extensive ISO language database.