Flutter dynamically load translation in your app.

Overview

Dynamically load translation in your app.

Getting started

Initiate I18n in your dart's main() {}

void main() {
    // ...

    I18n.init(
        url: 'https://www.example.com',
        locale: 'hi',
        locales: ['en', 'hi', 'pa'],
    );

    // ... 
}

Now you can use I18n.builder anywhere in your code

Column(
    children: [
        // example 1: for Text
        I18n.text('Who am I ?'), // Text('मैं कौन हूँ ?')

        // example 2: with builder
        // first build with given locale
        // rebuild after translation fetching
        I18n.builder('Who am I ?', (translatedText) {
            return Text(translatedText);
        }),

        // example 3: with childBuilder
        I18n.childBuilder(
            'Who am I ?',
            (translatedText, child) {
                return Column(
                children: [
                    Text(translatedText),
                    child, // same on both first and second build
                ],
                );
            },
            Container(), // will be reused in rebuild
        ),
    ],
);

Server Setup

Set your server to respond in this way.

Request Method: GET
Request URL: https://www.example.com/hi.json

Response
Content-Type: application/json

[
    {'en': 'How are you ?', 'hi': 'आप कैसे हो ?'},
    {'en': 'Who am I ?', 'hi': 'मैं कौन हूँ ?'},
]

For single translation request library will send POST request in this format to url you have provided in I18n.init, according to above example it will be

Request Method: POST
Request URL: https://www.example.com/hi

{
    'en': sourceText,
    'target': targetLocale,
}

Response
Content-Type: application/json

{'en': 'How are you ?', 'hi': 'आप कैसे हो ?'}
You might also like...

Tool made in Dart that allows you to dynamically generate JSON files from data models written in Dart.

Dart JSON Generator Versión v1.1.1 Dart JSON Generator es una herramienta que permite generar archivos JSON a partir de mapas como modelos de datos en

Nov 23, 2022

A font loader to download, cache and load web fonts in flutter with support for Firebase Cloud Storage.

A font loader to download, cache and load web fonts in flutter with support for Firebase Cloud Storage.

Dynamic Cached Fonts A simple, easy to use yet customizable font loader to use web fonts. Demo: https://sidrao2006.github.io/dynamic_cached_fonts 👋 I

Dec 21, 2022

A flutter widget that provides pull-down refresh and pull-up load.

A flutter widget that provides pull-down refresh and pull-up load.

flutter_easyrefresh English | 中文 正如名字一样,EasyRefresh很容易就能在Flutter应用上实现下拉刷新以及上拉加载操作,它支持几乎所有的Flutter控件。它的功能与Android的SmartRefreshLayout很相似,同样也吸取了很多三方库的优点。

Jan 8, 2023

A small library support load infinite for ListView - GridView on Flutter.

A small library support load infinite for ListView - GridView on Flutter.

Paging A Flutter package that supports pagination(load infinite) for ListView, GridView Demo DataSource PageKeyedDataSource To create a PagingListView

Dec 4, 2022

Simple flutter package to load and search string.

Simple flutter package to load and search string.

flutter_text_viewer flutter_text_viewer is a simple text viewer package to load and search text from assets,file. Demo Features Load text from assets/

Dec 15, 2022

A command-line application provide an load optimization solution for flutter web

A command-line application provide an load optimization solution for flutter web

一个命令行工具,针对flutter web加载慢和缓存问题提供了一套解决方案。 功能 通过大文件分片和资源文件cdn化方式,优化flutter web页面加载慢问题。 通过资源文件hash化,解决浏览器强缓存导致功能无法更新问题。 开始 局部安装 dev_dependencies: flutte

Dec 29, 2022

A library for widgets that load their content one page (or batch) at a time.

A library for widgets that load their content one page (or batch) at a time.

A library for widgets that load their content one page (or batch) at a time (also known as lazy-loading and pagination). Features Load data one page a

Oct 20, 2022

Aris inheritedwidget - The Inherited Widget helps you to easily distribute your app state to every widget in your Flutter app

Aris inheritedwidget - The Inherited Widget helps you to easily distribute your app state to every widget in your Flutter app

Flutter Tutorial - Inherited Widget The InheritedWidget helps you to easily dist

Dec 29, 2021

BubbleShowcase is a small but power flutter package that allows you to highlight specific parts of your app to explain them to the user or to showcase your app new features.

BubbleShowcase BubbleShowcase is a small but powerful flutter package that allows you to highlight specific parts of your app (to explain them to the

Oct 26, 2022
Owner
null
A Flutter widget to dynamically add links to your text.

linkable A Flutter widget to add links to your text. By default, the Text or RichText widgets render the URLs in them as simple text which are not cli

Anup Kumar Panwar 18 Dec 15, 2021
Biyi - a convenient translation and dictionary app written in Flutter

biyi_app Biyi is a convenient translation and dictionary app written in Flutter.

biyidev 892 Dec 28, 2022
A simple Quran package for flutter with arabic text, english translation, bangla language and pronunciation

A simple Quran package for flutter with arabic text, english translation, bangla language and pronunciation. Also available audio link, revelation type and other information.

Khalid Hassan 2 Oct 10, 2022
A program for Mac, Windows and Linux to manage multiple translation files at once

A program for Mac, Windows and Linux to manage multiple translation files at once. Easy to use UI, multithreaded for optimization and Google Translate natively integrated. NB: At the moment it doesn't support nested translation keys.

Jesper Paulsen 4 Aug 8, 2022
A future based dart package for the NLT (New Living Translation) API.

NLT API Bible for Dart A future based dart package for the NLT API from Tyndale which can be used to fetch NLT and KJV bible passages. This package re

Ariel Magbanua 3 Nov 17, 2022
Dynamically themed Music Player built with flutter

?? Flutter Music Player Contact me email: [email protected] Gitter: https://gitter.im/Moda20TuneIn/community Thank you in advance ?? Getting Started

null 135 Dec 31, 2022
A Flutter plugin than allow expand and collapse text dynamically

readmore A Flutter plugin than allow expand and collapse text. usage: add to your pubspec readmore: ^1.0.2 and import: import 'package:readmore/readm

Jonny Borges 173 Dec 28, 2022
A Flutter package used to update widget tree dynamically

简体中文|English Fair is a lightweight package for Flutter, which can be used to update widget tree and state dynamically. This package is still at an ear

Wuba 1.8k Dec 30, 2022
Polymaker is an application that can create polygon locations dynamically in mobile apps and save the data into SQFlite to be permanent.

Polymaker Polymaker is an application that can create polygon locations dynamically in mobile apps and save the data into SQFlite to be permanent. Ins

Yusril Rapsanjani 15 Apr 17, 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