Search packages, repositories and app categories

Package detailsv0.7.0

json_localizations

A minimal JSON localization package built on LocalizationsDelegate.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
36
Likes
2
Pub points
150

Install package

flutter pub add json_localizations

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A lightweight JSON-based localization package built on Flutter's LocalizationsDelegate. It enables easy management of localized strings by loading translations from JSON files, supporting multiple languages and dynamic language switching. Designed for simplicity and integration with Flutter’s internationalization system, it allows developers to maintain clean, readable translation files without complex setup. Ideal for apps requiring straightforward multilingual support with minimal overhead.

Use cases

  • Multi-language app support
  • Dynamic language switching
  • Simple translation file management
  • Embedding translations in assets
  • Lightweight localization solution
  • Customizable locale fallback

Key features

  • JSON-based translation files
  • Extends LocalizationsDelegate
  • Supports multiple locales
  • Easy asset integration
  • Minimal boilerplate
  • Fallback locale handling

Suitable for

  • Small to medium-sized apps
  • Developers seeking simplicity
  • Projects with static translations
  • Teams using JSON for localization
  • Apps needing basic i18n
  • Fast prototyping

Considerations

  • Not ideal for large-scale translation workflows
  • No built-in translation editing tools
  • Manual JSON file management
  • Limited support for pluralization
  • No automatic key extraction
  • Requires manual locale setup

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

json_localizations

A minimal JSON localization package for Flutter.

Use a JSON file/object per language to represent key/value pairs for localizing your app.

Install

Add json_localizations and flutter_localizations as dependencies to your pubspec.yaml.

dependencies:
  flutter_localizations:
    sdk: flutter
  json_localizations:
Add a JSON file per language

Add a JSON file per language you support in an asset path and describe it in your pubspec.yaml

flutter:
  assets:
    - assets/json_translations/

The JSON file name must match exactly the combination of language and country code described in supportedLocales.

That is Locale('en', 'US') must have a corresponding assetPath/en-US.json file.

Add JsonLocalizationsDelegate to MaterialApp

Add JsonLocalizationsDelegate to MaterialApp and set supportedLocales using language/country codes.

MaterialApp(
  localizationsDelegates: [
    // delegate from flutter_localization
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
    // delegate from json_localizations
    JsonLocalizationsDelegate('assets/json_translations'),
  ],
  supportedLocales: [
    Locale('en'),
    Locale('nb'),
  ],
}

Note on iOS

Add supported languages to ios/Runner/Info.plist as described here.

Example:

<key>CFBundleLocalizations</key>
<array>
	<string>en-GB</string>
	<string>en</string>
	<string>nb</string>
</array>

Format

Example JSON file:

{
	"hello": "hello",
	"bye": "bye",
	"items": [ "one", "two", "three" ],
	"count": 1
}

Tip: You can store any json type given a key, like a string, an array of strings, or a number

API

Get a value for the current language using:

JsonLocalizations.of(context)?.value('hello')

We keep the API simple, but you could easily add an extension method to String:

extension LocalizedString on String {
  String tr(BuildContext context) => JsonLocalizations.of(context)!.value(this);
}

So you could write:

'hello'.tr(context)

Example

See example.

Categories

Source repository

Projects using this package

No data available yet.