Search packages, repositories and app categories

Package detailsv0.4.1

intl_generator

Contains code to deal with internationalized/localized messages, date and number formatting and parsing, bi-directional text, and other internationalization issues.

AndroidiOSmacOSWindowsLinux
30-day downloads
1.6K
Likes
25
Pub points
110

Install package

flutter pub add intl_generator

Package Overview

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

The intl_generator package provides code generation tools for handling internationalization in Flutter apps. It supports localized messages, date and number formatting, parsing, and bidirectional text rendering. By generating Dart code from message files, it enables efficient and type-safe localization without runtime overhead. The package integrates seamlessly with the intl library, making it easier to manage translations across multiple languages and platforms.

Use cases

  • Generating localized strings from .arb files
  • Formatting dates and numbers per locale
  • Supporting right-to-left languages
  • Managing multilingual app content
  • Automating translation workflows

Key features

  • Code generation from ARB files
  • Type-safe localization
  • Built-in support for pluralization
  • Integration with intl library
  • Platform-agnostic localization

Suitable for

  • Flutter apps targeting global audiences
  • Teams managing multiple language translations
  • Projects requiring high-performance localization
  • Developers using ARB for message management
  • Apps needing consistent date/number formatting

Considerations

  • Requires setup of ARB files
  • Needs build step for code generation
  • Limited runtime customization
  • Depends on intl library
  • Not suitable for dynamic language switching

Original README

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

Intl_generator

This is a fork of intl_translation to have an up to date version.

If you prefer having translations as part of your build_runner process or need to support flavors, please check intl_flavors

This package provides message extraction and code generation from translated messages for the Intl package. It's a separate package so as to not require a dependency on analyzer for all users.

Extracting And Using Translated Messages

When your program contains messages that need translation, these must be extracted from the program source, sent to human translators, and the results need to be incorporated.

To extract messages, run the extract_to_arb.dart program.

  pub run intl_generator:extract_to_arb --output-dir=target/directory
      my_program.dart more_of_my_program.dart

This will produce a file intl_messages.arb with the messages from all of these programs. This is an ARB format file which can be used for input to translation tools like Localizely or (the deprecated) Google Translator Toolkit. The resulting translations can be used to generate a set of libraries using the generate_from_arb.dart program.

This expects to receive a series of files, one per locale.

pub run intl_generator:generate_from_arb --generated-file-prefix=<prefix>
    <my_dart_files> <translated_ARB_files>

This will generate Dart libraries, one per locale, which contain the translated versions. Your Dart libraries can import the primary file, named <prefix>messages_all.dart, and then call the initialization for a specific locale. Once that's done, any Intl.message calls made in the context of that locale will automatically print the translated version instead of the original.

import "my_prefix_messages_all.dart";
...
initializeMessages("dk").then(printSomeMessages);

Once the Future returned from the initialization call completes, the message data is available.

Categories

Dependencies

Dependency list 7 items

Source repository

Projects using this package