Search packages, repositories and app categories

Package detailsv2.8.0

toml_localizations

A minimal TOML localization package built on LocalizationsDelegate.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
94
Likes
3
Pub points
150

Install package

flutter pub add toml_localizations

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A lightweight Flutter package for managing app translations using TOML (Tom's Obvious, Minimal Language) files. Built on Flutter's LocalizationsDelegate, it enables easy integration of localized strings by loading key-value pairs from TOML files. The package supports multiple locales and simplifies translation workflows with a clean, human-readable format. Ideal for developers seeking a minimal, structured alternative to JSON or YAML for localization. It works across all major Flutter platforms including Android, iOS, Web, macOS, Windows, and Linux.

Use cases

  • Managing multilingual app content
  • Loading translations from TOML files
  • Simplifying localization setup in Flutter apps
  • Supporting dynamic language switching
  • Integrating structured text files for translations

Key features

  • TOML-based translation files
  • Minimal dependency footprint
  • Built on LocalizationsDelegate
  • Cross-platform support
  • Easy-to-read configuration format
  • Automatic locale detection

Suitable for

  • Developers preferring TOML over JSON/YAML
  • Projects requiring lightweight localization
  • Teams using structured text formats
  • Apps targeting multiple languages
  • Flutter apps needing simple translation management

Considerations

  • Requires manual setup of TOML files
  • Limited to basic string translations
  • No built-in translation editing tools
  • TOML parsing may be less familiar than JSON
  • Not suitable for complex localization structures

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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.

Install

Add toml_localizations and flutter_localizations as dependencies to your pubspec.yaml.

dependencies:
  flutter_localizations:
    sdk: flutter
  toml_localizations: <last-version>
Add assets

Add a TOML file per language to a asset path and define 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.

Add localization delegate and supported locales

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

MaterialApp(
  localizationsDelegates: [
    // delegate from flutter_localization
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
    // toml localizations delegate
    TomlLocalizationsDelegate(path: 'assets/toml_translations')
  ],
  supportedLocales: [
    Locale('en', 'GB'),
    Locale('en', 'US'),
    Locale('en'),
    Locale('nb'),
  ],
}
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>

Format

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.

API

Translate strings or other types using:

TomlLocalizations.of(context)!.value(this);

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);
}

Se you could translate strings like this:

'Hi'.tr(context)

Example

See example

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package

No data available yet.