Giter Club home page Giter Club logo

intl_utils's Introduction

Intl Utils

Dart package that creates a binding between your translations from .arb files and your Flutter app. It generates boilerplate code for official Dart Intl library and adds auto-complete for keys in Dart code.

Follow us on Twitter.

Usage

You can use this package directly (i.e. for Continuous Integration tools or via CLI) or leave it to Visual Studio Code or IntelliJ/Android Studio plugins to run it automatically whenever you modify ARB files.

Follow these steps to get started:

Configure package

Add package configuration to your pubspec.yaml file. Here is a full configuration for the package:

flutter_intl:
  enabled: true # Required. Must be set to true to activate the package. Default: false
  class_name: S # Optional. Sets the name for the generated localization class. Default: S
  main_locale: en # Optional. Sets the main locale used for generating localization files. Provided value should consist of language code and optional script and country codes separated with underscore (e.g. 'en', 'en_GB', 'zh_Hans', 'zh_Hans_CN'). Default: en

  localizely: # Optional settings if you use Localizely platform. Read more: https://localizely.com/flutter-localization
    project_id: # Get it from the https://app.localizely.com/projects page.
    upload_overwrite: # Set to true if you want to overwrite translations with upload. Default: false
    upload_as_reviewed: # Set to true if you want to mark uploaded translations as reviewed. Default: false
    ota_enabled: # Set to true if you want to use Localizely Over-the-air functionality. Default: false

Add ARB files

Add one ARB file for each locale you need to support in your Flutter app. Add them to lib/l10n folder inside your project, and name them in a following way: intl_<LOCALE_ISO_CODE>.arb. For example: intl_en.arb or intl_en_GB.arb.

If you wonder how to format key-values content inside ARB files, here is detailed explanation.

Run command

To generate boilerplate code for localization, run the generate program inside directory where your pubspec.yaml file is located:

  flutter pub run intl_utils:generate

This will produce files inside lib/generated directory.

Integration with Localizely

Upload main ARB file

  flutter pub run intl_utils:localizely_upload_main --project-id <PROJECT_ID> --api-token <API_TOKEN>

This will upload your main ARB file to Localizely. Check out the 'Configure package' section for additional upload configuration.

Download ARB files

  flutter pub run intl_utils:localizely_download --project-id <PROJECT_ID> --api-token <API_TOKEN>

This will download all available ARB files from the Localizely platform and put them under lib/l10n folder inside your project.

Notes: Argument project-id can be omitted if pubspec.yaml file contains project_id configuration under flutter_intl/localizely section. Argument api-token can be omitted if ~/.localizely/credentials.yaml file contains api_token configuration.

intl_utils's People

Contributors

lzoran avatar goranluledzija avatar

Watchers

James Cloos 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.