dalocale 1.5.0

Dalocale #

A Flutter package to easily support internationalization and localization in your project.

Installation #

Add the following dependencies to your pubspec.yaml:

    sdk: flutter 

  dalocale: ^1.5.0

Example #

Creating localization files #

Create a folder to store all the localizations in json format. The name of each file should match the locale that is representing. For example:

└─ assets
   └─ i18n
      ├─ en.json
      └─ es.json

Each localization file must contain a single json object with all the keys and values. For example:

    "greetings": "Hello, world!",
    "welcome.back": "Welcome back: %1$s"

In the previous example, the key welcome.back contains a value with a parameter.

Parameters #

Parameters inside of localized text must be declared as %index$format, where:

  • index: the position of the parameter in the text (starting from 1)
  • format: the format of the parameter (e.g. s, d, f, etc.)

Generating Dart code #

To generate the Dart file containing all the localizations, run the following command:

flutter pub pub run dalocale:dalocale.dart INPUT_FOLDER OUTPUT_FILE [DEFAULT_LOCALE]

For example:

flutter pub pub run dalocale:dalocale.dart ./assets/i18n/ ./lib/foo/bar/localizations.dart en

Using generated code #

In you main.dart file, add the auto-generated classes CustomLocalizationsDelegate and Localized to the app:

import 'package:flutter/material.dart';
import 'package:flutter_library/foo/bar/localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

void main() {

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      home: ...,
      localizationsDelegates: const [
      supportedLocales: Localized.locales,

You can use the class Localized to have access to all the entries declared in the json files:


[1.0.0] - 2019-06-23

  • First version

[1.2.1] - 2019-06-23

  • Renamed main script to dalocale.dart

[1.3.0] - 2019-06-24

  • Improved generator script

[1.3.1] - 2019-06-25

  • Fixed bug escaping single quotes

[1.4.0] - 2019-06-27

  • Added lint rules

[1.5.0] - 2019-06-30

  • Changed parameter system


Example #

Example available in the main README.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dalocale: ^1.5.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dalocale/dalocale.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

1 out of 1 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_localizations 0.0.0
path ^1.6.2 1.6.2
Transitive dependencies
collection 1.14.11
intl 0.15.8
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies