TOML localization for Flutter

Overview

toml_localizations

A minimal TOML localization package for Flutter.

TOML is a minimal, easy to read, configuration file format, which allows you to represent strings (and other types) as key/value pairs.

Usage

See example.

Install

Add to your pubspec.yaml

dependencies:
  toml_localizations:

Add a TOML file per language

Add a TOML file per language you support in an asset path and describe it in your pubspec.yaml

flutter:
  assets:
    - assets/toml_translations

The TOML file name must match exactly the combination of language and country code described in supportedLocales.

That is Locale('en', 'US') must have a corresponding assetPath/en-US.toml file.

Example TOML file
str = "The quick brown fox jumps over the lazy dog."

literal_str = 'C:\Users\nodejs\templates'

multiline_str = """\
The quick brown \
fox jumps over \
the lazy dog.\
"""

literal_multiline_str = '''
The first newline is
trimmed in raw strings.
   All other whitespace
   is preserved.
'''

list = [ 'one', 'two', 'three' ]

Tip: Toml supports several ways of expressing strings. See Toml documentation for more info.

MaterialApp

Add TomlLocalizationsDelegate to MaterialApp and set supportedLocales using language/country codes.

MaterialApp(
  localizationsDelegates: [
    ... // global delegates
    TomlLocalizationsDelegate('assets/toml_translations')
  ],
  supportedLocales: [
    Locale('en', 'GB'),
    Locale('en', 'US'),
    Locale('en'),
    Locale('nb'),
  ],
}

API

Translate strings or other types using

TomlLocalizations.of(context)!.value('Hi')

We keep the API simple, but you can easily add an extension method to String like this:

extension LocalizedString on String {
  String tr(BuildContext context) => TomlLocalizations.of(context)!.value(this);
}

Note on iOS

Add supported languages to ios/Runner/Info.plist as described here.

Example:

<key>CFBundleLocalizations</key>
<array>
	<string>en</string>
	<string>en-GB</string>
	<string>en-US</string>
	<string>nb</string>
</array>
You might also like...

Internationalization and localization support

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

Dec 21, 2022

GetX Architecture for large scale project, This project include - pagination, pull to refresh, localization, network call and advance error handling

GetX Architecture for large scale project, This project include - pagination, pull to refresh, localization, network call and advance error handling

Nov 29, 2022

WIP: generate easy localization key code

Generates translation key code for the easy localization package. Support for json and yaml formats.You can see examples in the assets/ folder. Gettin

Oct 24, 2022

šŸ†™šŸš€ Flutter application upgrade/ Flutter App Upgrade /Flutter App Update/Flutter Update / download Plug-in

šŸ†™šŸš€  Flutter application upgrade/ Flutter App Upgrade /Flutter App Update/Flutter Update / download Plug-in

šŸ†™šŸš€ Flutter application upgrade/ Flutter App Upgrade /Flutter App Update/Flutter Update / download Plug-in (with notice bar progress), supports full upgrade, hot update and incremental upgrade

Dec 30, 2022

ABC of Flutter widgets. Intended for super beginners at Flutter. Play with 35+ examples in DartPad directly and get familiar with various basic widgets in Flutter

ABC of Flutter widgets. Intended for super beginners at Flutter. Play with 35+ examples in DartPad directly and get familiar with various basic widgets in Flutter

Basic Widgets Examples This is aimed for complete beginners in Flutter, to get them acquainted with the various basic widgets in Flutter. Run this pro

Jan 3, 2023

Minha primeira aplicaĆ§Ć£o android utilizando Flutter feito no curso de Flutter da Cod3r Cursos Online. O foco dessa aplicaĆ§Ć£o foi um contato inicial com o Flutter.

Minha primeira aplicaĆ§Ć£o android utilizando Flutter feito no curso de Flutter da Cod3r Cursos Online. O foco dessa aplicaĆ§Ć£o foi um contato inicial com o Flutter.

expenses Expenses Ć© uma aplicaĆ§Ć£o android simples feita em Flutter para controlar despesas pessoais. A aplicaĆ§Ć£o consiste em: Listar transaƧƵes feitas

Apr 19, 2022

Flutter Github Following Application, Using Flutter Provider and Flutter HTTP to get data from Github API.

Flutter Github Following Application, Using Flutter Provider and Flutter HTTP to get data from Github API.

Flutter Github Following Application Watch it on Youtube Previous Designs Checkout my Youtube channel Installation Please remember, after cloning this

Dec 23, 2022

Flutter RSS feed parsing - A demo application of flutter which parse RSS XML contents to the flutter application

Flutter RSS feed parsing - A demo application of flutter which parse RSS XML contents to the flutter application

Flutter RSS feed parsing demo This is demo application of flutter which shows ho

Nov 15, 2022

Flutter mapbox - This Flutter plugin allows to show embedded interactive and customizable vector maps inside a Flutter widget

Flutter mapbox - This Flutter plugin allows to show embedded interactive and customizable vector maps inside a Flutter widget

Flutter Mapbox GL Please note that this project is community driven and is not a

Jan 31, 2022
A basic boilerplate template for starting a Flutter GetX project. GetX, Dio, MVVM, get CLI, Localization, Pagination etc are implemented.

Flutter GetX Template (GetX, Dio, MVVM) This Flutter Template using GetX package for State management, routing and Dependency Injection (bindings). We

Hasan Abdullah 214 Jan 9, 2023
Flutter localization in easy steps

localize_and_translate Flutter localization in easy steps Share your love to this ā¤ļø Screenshots Tutorial Video Arabic : https://www.youtube.com/watch

Mohamed Sayed 48 Aug 9, 2022
Yet another localization approach in Flutter

Flutter Global Summit Vol.2 schedule Source code of the mobile application that displays the schedule of the Flutter Global Summit Vol.2 conference th

Anna Leushchenko 3 Mar 24, 2022
Kurdish localization for flutter

Flutter Kurdish Localization ?? This package provides unofficial localization su

Amin Samad 16 Oct 25, 2022
"FlutterMoneyFormatter" is a Flutter extension to formatting various types of currencies according to the characteristics you like, without having to be tied to any localization.

FlutterMoneyFormatter FlutterMoneyFormatter is a Flutter extension to formatting various types of currencies according to the characteristics you like

Fadhly Permata 81 Jan 1, 2023
A tool which automatically generates Flutter localization resources from CSV and Excel files.

flappy_translator A tool which automatically generates Flutter localization resources from CSV and Excel files. This is especially useful as any team

Smart&Soft 55 Sep 15, 2022
Flutter project. The sample of Localization.

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

Aoi Umigishi 1 Jan 5, 2022
Create flutter project with all needed configuration in two minutes (theme, localization, connect to firebase, FCM, local notifications, safe API call, error handling, animation..etc)

Flutter GetX Template Flutter Getx template to make starting project fast and easy . Introduction We all face the same problem when we want to start a

Emad Beltaje 150 Jan 7, 2023
Generates a new Flutter app with http client, theme, routing and localization features.

Starter Template Generates a new Flutter app with http client, theme, routing and localization features. Brick Uses: dio as http client pretty_dio_log

Cem Avcı 12 Nov 3, 2022
Note provider - Note App using Provider state management, Sqflite and Localization for two language Arabic and English.

note_provider Sqflite with provider statemanagement Getting Started This project is a starting point for a Flutter application. A few resources to get

Mohanned Anwar 0 Jan 1, 2022