Book Image

DART Cookbook

By : Ivo Balbaert
Book Image

DART Cookbook

By: Ivo Balbaert

Overview of this book

Table of Contents (18 chapters)
Dart Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Internationalizing a Polymer app


What if you want your web app to display information in several languages, depending on the language of the web client user? This recipe will show you how to accomplish this. You can find the code in the project pol_intl.

How to do it...

  1. Add the intl package from the pub package to your app through pubspec.yaml.

  2. The script starts with web\pol_intl.html, where a component with the name localized_text is imported through the following line:

    <link rel="import"href="localized_text.html">

    From this, we know that the component is defined in localized_text.html, and the code behind it is in a file named localized_text.dart. For a discussion of the other tags, see the first recipe.

  3. The structure of the component is outlined in localized_text.html:

    <link rel="import"href="packages/polymer/polymer.html">
    <polymer-element name="localized-text">
    <template>
    <p>{{startMsg}}</p>
    
    <select value="{{selectedLocale}}">
    <option value="en_US...