Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.

Overview

Build Status pub package Awesome Flutter License: MIT Flutter.io


Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.

It lets you define translations for your content in different languages and switch between them easily.

Example

Features

  • Very easy to use
  • Mobile, Web and Desktop support
  • Pluralization and Duals support
  • Static keys support with flutter_translate_gen
  • Supports both languageCode (en) and languageCode_countryCode (en_US) locale formats
  • Automatically save & restore the selected locale with a simple implementation
  • Full support for right-to-left locales
  • Fallback locale support in case the system locale is unsupported
  • Supports both inline or nested JSON

Documentation

Complete documentation is available on the wiki page.

To get started please see Installation, Configuration & Usage.

Examples

Issues

Please file any issues, bugs or feature request here.

License

This project is licensed under the MIT License

Author

This Flutter package is developed by Florin Bratan. You can contact me at [email protected]

Comments
  • Add an option to automatically sync the current locale with the system locale

    Add an option to automatically sync the current locale with the system locale

    Add an option to automatically sync the current locale with the system locale.

    So when the system locale is changed, the current/app locale will be reloaded as well (if supported).

    Reference: https://github.com/bratan/flutter_translate/issues/20

    enhancement wontfix 
    opened by bratan 11
  • fallback to fallback locale for missing strings in translation file

    fallback to fallback locale for missing strings in translation file

    Currently, if a translation file is incomplete (i.e. a key is missing), then we will show the key instead of a translation. But for me it would be more intuitive to fallback to the fallbackLocale in these cases.

    This allows to iteratively translate an App and if something is forgotten or not yet translated, we have a more meaningful placeholder.

    Currently, I just load both translation maps (the chosen locale and the fallback locale) and then fallback during lookup. Another alternative is to merge the maps in the beginning and then just have one translation map.

    Let me know, what you think. We could also make this a setting.

    opened by cornerman 10
  • Get list from translation file

    Get list from translation file

    I have a dynamic list showing some descriptions like this:

    List<Map> descriptions = [
    "title":  "My title",
    "description": ["description1", "description2"]
    ];
    

    How could I get this from the translation json file?

    wontfix 
    opened by erperejildo 7
  • Migration to Null-safety

    Migration to Null-safety

    Migration to null-safety Dependencies upgraded Example Android Folder upraged to support dart 2 Added pt-BR as translation example Formated Lib folder to pub.dev patterns with dartfmt command

    opened by rafaelsetragni 7
  • Flutter Drive not working with flutter_translate

    Flutter Drive not working with flutter_translate

    Problem: when you test your app with Flutter Drive - app will stay on White screen while trying to init the app.

    To be more specific, this call is never executes: final delegate = await LocalizationDelegate.create(fallbackLocale: 'en_US', supportedLocales: ['en_US']);

    Root cause of the issue is inside locale_file_service.dart - Future getLocaleContent(String file) method.

    This code hangs:

    return rootBundle.loadString(file);

    This code will work:

    static Future<String> getLocaleContent(String file) async
        {
            final ByteData data = await rootBundle.load(file);
            if (data == null) return null;
            return utf8.decode(data.buffer.asUint8List());
        }
    

    Underlying reason for that (if qurious to read) is here: https://github.com/flutter/flutter/issues/24703

    opened by AlexBacich 7
  • allow locales to be outside of the rootBundle

    allow locales to be outside of the rootBundle

    Hi!

    Actually it is not possible to have your locales outside of the rootBundle. This is needed in cases where you download your locales over network and can't have them in the rootBundle.

    greetz

    opened by volmus 6
  • Added support for list of strings

    Added support for list of strings

    What

    Added support to translate a list of strings.

    Why

    For a project I'm working on I needed to get a list of strings to display in a random way (ex.: a pseudo bot that says different sentences for a specific action) using the nested json feature provided by lokalise (link to specific doc page).

    Example

    json:

    {
       "level_1": {
          "attack": [
              "Your attack was effective",
              "You hit your enemy!"
          ]
       }
    }
    

    flutter:

    import "dart:math";
    import 'package:flutter/material.dart';
    import 'package:flutter_translate/flutter_translate.dart';
    
    class FightFeedback extends StatelessWidget {
    
      @override
      Widget build(BuildContext context) {
        final rnd = Random();
        final messages = translateList('level_1.attack');
        final message = messages[rnd.nextInt(messages.length)];
    
        return Text(message);
      }
    }
    
    opened by Skogsfrae 6
  • Pluralization feature not working for static keys

    Pluralization feature not working for static keys

    It seems like the generation of plural keys is not working correctly at the moment. The generated keys file in the static_keys example does not generate the key "Plural.demo", only the children of it (Plural.demo.zero etc.). Which in turn gives a compilation error when I try to use the key in my widget, as the key does not exist.

    I thought originally i was doing something wrong, but the generated files in the example also does this.

    image

    Am i correct in assuming that the example will not work either? Or am i doing something wrong when i get the compilation error when running:

    translatePlural(Keys.Plural_Demo, _counter)

    wontfix 
    opened by oysteinhodne 5
  • Error when building iOS app

    Error when building iOS app

    Getting the following error after upgrading to 4.0.0:

    ../../../Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_translate-4.0.0/lib/src/utils/device_locale.dart:11:49: Error: Property 'window' cannot be accessed on 'WidgetsBinding?' because it is potentially null.
         - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Flutter/flutter/packages/flutter/lib/src/widgets/binding.dart').
        Try accessing using ?. instead.
          final deviceLocales = WidgetsBinding.instance.window.locales;
    

    Flutter Doctor output:

    Flutter (Channel stable, 2.10.5, on macOS 12.3.1 21E258 darwin-arm, locale
        en-DE)
        • Flutter version 2.10.5 at /Users/janbrinkmann/Flutter/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 5464c5bac7 (2 weeks ago), 2022-04-18 09:55:37 -0700
        • Engine revision 57d3bac3dd
        • Dart version 2.16.2
        • DevTools version 2.9.2
    
    opened by JanBrin 5
  • Retrieve the current device locale and initialize it before runApp

    Retrieve the current device locale and initialize it before runApp

    Fixes issue #13 and possibly #14 but I don't have an iOS device to test on. Takes into account if there are preferences on the device and if not loads the device locale.

    opened by CEOSiyris 5
  • [ERROR:flutter/lib/ui/ui_dart_state.cc(207)] Unhandled Exception: Unable to load asset: assets/i18n/en.json

    [ERROR:flutter/lib/ui/ui_dart_state.cc(207)] Unhandled Exception: Unable to load asset: assets/i18n/en.json

    I keep receiving this message when i run my program. if i add flutter: assets:

    • assets/i18n

    then i receive message No file or variants found for asset: assets/i18n.

    opened by xmartinez22 4
  • Add translateIfExists API which returns null if the translation key i…

    Add translateIfExists API which returns null if the translation key i…

    Add translateIfExists API which returns null if the translation key is not found. This enables the caller to know that the translation is not available and act accordingly.

    opened by kristofb 0
Releases(3.0.0)
Owner
Florin Bratan
Florin Bratan
gen_lang is a dart library for internationalization. Extracts messages to generate dart files required by Intl, inspired by Intl_translation and Flutter i18n

gen_lang gen_lang is a dart library for internationalization. Extracts messages to generate dart files required by Intl. Now, three steps for internat

kw101 93 Oct 18, 2022
Flutter app backed by Redux, shows animations, internationalization (i18n), ClipPath, fonts and others...

A Flutter tourism app that is backed-by Redux, shows animations, internationalization (i18n, English <=> Arabic), ClipPath, and fonts. YouTube demo I

Abdulmomen Kadum عبدالمؤمن كاظم 277 Dec 28, 2022
Internationalization and localization support

Provides internationalization and localization facilities, including message translation, plurals and genders, date/number formatting and parsing, and

Dart 497 Dec 21, 2022
A fully-featured Last.fm client and scrobbler with Shazam-like scrobbling, a collage generator, home screen widgets, and more!

Finale A fully-featured Last.fm client and scrobbler with Shazam-like scrobbling, a collage generator, and more! The app is available on iOS, Android,

Noah Rubin 66 Jan 5, 2023
Fully Featured Chat App Using Firebase, RiverPod and much more.

LetsChat Fully Featured Chat App Using Firebase, RiverPod and much more. LetsChat app has a beautiful responsive UI. The app includes many features li

Mateen Mehmood 94 Dec 6, 2022
Turkmen localization flutter - Support for turkmen localization in flutter

Localization for turkmen language Unfortunately, I didn't find any support for t

Atamyrat Babayev 3 Nov 8, 2022
A universal translate client.

uni_translate A universal translate client.

biyidev 16 Dec 12, 2022
Dynamically translate text

auto_localization A new Flutter plugin. Flutter package to dynamically translate your app. This plugin will AUTOMATICALLY detect the app Localization

Matteo Sipione 5 Jan 27, 2022
I18n made easy, for Flutter!

flutter_i18n I18n made easy, for Flutter! Table of contents Why you should use flutter_i18n? Loaders FileTranslationLoader NetworkFileTranslationLoade

Matteo Pietro Dazzi 199 Dec 14, 2022
A Full-Featured Mobile Browser App (such as the Google Chrome mobile browser) created using Flutter and the features offered by the flutter_inappwebview plugin.

Flutter Browser App A Full-Featured Mobile Browser App (such as the Google Chrome mobile browser) created using Flutter and the features offered by th

Lorenzo Pichilli 270 Jan 2, 2023
Lightweight i18n solution for Flutter

fast_i18n Lightweight i18n solution. Use JSON, YAML or CSV files to create typesafe translations. About this library ?? Minimal setup, create JSON fil

Tien Do Nam 186 Dec 26, 2022
Alternative i18n tool for Dart and Flutter.

Simple internationalization (i18n) package for Dart and Flutter. Supports: AngularDart Flutter hot reload deferred loading of translations social dist

fnx.io 32 Dec 10, 2022
An instantly ready, full-featured alerts for development on any platform with flutter

An instantly ready, full-featured alerts for development on any platform with flutter. Enabling you to complete projects and deploy quickly. With QuickAlert, you can display animated alert dialogs such as success, error, warning, confirm, loading or even a custom dialog.

Belovance 16 Dec 18, 2022
A full-featured (simple message, voice, video) flutter chat application by SignalR and WebRTC

flutter_chat A full-featured (simple message, voice, video) flutter chat application by SignalR and WebRTC. Features Full Authentication service Bad r

WebDevYCH 4 Dec 11, 2022
An expressive, functional, and full-featured server-side framework for Dart.

A framework and collection of packages for writing http servers, built on top of the shelf package. This framework is intended to reduce the technical

Marathon 45 Jun 25, 2022
Small sample app to work on simplifying the i18n process

l10n_s12n A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if thi

Shi-Hao Hong 11 Jul 19, 2020
COVID-19 application made with Flutter, following Test Driven Development (TDD) and Clean Architecture along with Internationalization with JSON.

Covid App COVID-19 application made with Flutter, following Test Driven Development (TDD) and Clean Architecture along with Internationalization with

Sandip Pramanik 4 Aug 4, 2022
Flutter demo for internationalization.

Localizing your application 1. Introduction We are going to localize our application using the intl package. This guide is based on Flutter Docs - Int

Suman Adhikari 0 Dec 23, 2021
Flutter package: Easy and powerful internationalization using Dart extensions.

i18n_extension Non-boilerplate Translation and Internationalization (i18n) for Flutter Start with a widget with some text in it: Text("Hello, how are

Marcelo Glasberg 262 Dec 29, 2022
Easy and Fast internationalization for your Flutter Apps

Easy and Fast internationalization for your Flutter Apps Why easy_localization? ?? Easy translations for many languages ?? Load translations as JSON,

Aye7 672 Dec 18, 2022