Book Image

Dart By Example

By : David Mitchell
Book Image

Dart By Example

By: David Mitchell

Overview of this book

Table of Contents (17 chapters)
Dart By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Exploring the intl package


The intl package provides functionality for internationalization and localization of Dart applications. This not only includes the important aspect of translating interface text into other languages but also includes the formatting of text (not every language is formatted from left to right), dates and numbers.

Locating strings to translate

The interface of an application largely consists of buttons, with a few other labels and controls. A phrasebook of the application's interface language can be created using Intl.message and stored as static functions in the PhraseBook class, which can be found in the interfacetrans.dart file. This organizes all the strings that are to be set on the interface elements at runtime using the value or text properties:

class PhraseBook {
  // Navigation controls.
  static String btnFirstSlide() => Intl.message("First",
      name: "btnFirstSlide", desc: "Button label - go to the first slide.");

  static String btnPrevSlide() =&gt...