Code Monkey home page Code Monkey logo

dart_i18n's Introduction

dart_i18n

This package provides a lightweight and convenient mechanism for string localizations using simple yaml files.

How this works

  1. Create a directory specifically for localizatoin yaml files, eg. <root>/i18n/

  2. Create the first yaml file for your primary language, eg. <root>/i18n/en.yaml

  3. Upon your program starts, let dart_i18n know where your localization files are located, given relative path to root.

dart_i18n.setDefaultLocaliztion('i18n/en.yaml')

Here dart_i18n will take i18n as the directory that contains all the localization files and use en.yaml as current file.

  1. While you're writing code and need to use a string that may need localization, add it to the yaml file in hierarchy. For example,

Your code says:

print('hello.world'.localized);

You put into en.yaml

hello:
  world: Hello World!

What if you have variable in the string? For example

Your code says:

print('hello.you'.localize(['James']));

The en.yaml goes:

hello:
  world: Hello World! {}

Notes

Why use yaml over json?

Because yaml can have comments.

dart_i18n's People

Contributors

ifanchu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.