Search packages, repositories and app categories

Package detailsv1.6.0

yaml_localizations

A minimal YAML localization package built on LocalizationsDelegate.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
33
Likes
2
Pub points
150

Install package

flutter pub add yaml_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 YAML files, built on Flutter's LocalizationsDelegate. It enables easy internationalization by loading localized strings from YAML resources, simplifying the process of supporting multiple languages without complex setup. The package integrates seamlessly into Flutter apps across all major platforms, offering a clean and maintainable way to handle localization with minimal boilerplate. Ideal for developers seeking a straightforward alternative to JSON-based or hardcoded translation systems.

Use cases

  • Multi-language app support
  • Simple translation management
  • Integration with existing Flutter projects
  • Lightweight localization solution
  • Dynamic language switching

Key features

  • YAML-based translation files
  • Built on LocalizationsDelegate
  • Cross-platform compatibility
  • Minimal configuration
  • Easy to extend and maintain

Suitable for

  • Small to medium-sized apps
  • Developers preferring YAML over JSON
  • Projects needing quick i18n setup
  • Teams avoiding complex localization frameworks
  • Apps targeting multiple platforms

Considerations

  • Requires manual YAML file management
  • No built-in translation editing tools
  • Limited to string-based translations
  • Not ideal for large-scale translation workflows
  • No runtime translation updates

Original README

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

yaml_localizations

A minimal YAML localization package for Flutter.

YAML is a human-readable, configuration file format with a minimal syntax, which allows you to represent strings as key/value pairs in addition to other types.

YAML is the format used by Flutter's pubspec.yaml file.

Install

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

dependencies:
  flutter_localizations:
    sdk: flutter
  yaml_localizations:
Add a YAML file per language

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

flutter:
  assets:
    - assets/yaml_translations/

The YAML file name must match the language tag described in supportedLocales.

E.g. Locale('en', 'US') must have a corresponding assetPath/en-US.yaml file.

Add localizationDelegates and supportedLocales

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

MaterialApp(
  localizationsDelegates: [
    // global delegates
    ...GlobalMaterialLocalizations.delegates,
    // yaml localizations
    YamlLocalizationsDelegate(path: 'assets/yaml_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-GB</string>
	<string>en</string>
	<string>nb</string>
</array>

YAML format

Hi: Hi
Text: |
  There once was a tall man from Ealing
  Who got on a bus to Darjeeling
      It said on the door
      "Please don't sit on the floor"
  So he carefully sat on the ceiling
Long: >
  Wrapped text
  will be folded
  into a single
  paragraph

  Blank lines denote
  paragraph breaks

Tip: Yaml supports several ways of expressing strings. Use the vertical bar character to indicate that a string will span several lines. Use the greater-than character to break up long lines.

API

Translate strings using

YamlLocalizations.of(context)?.string('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) => YamlLocalizations.of(context)!.string(this);
}

So you can use it like this:

'Hi'.tr(context)

Example

See example

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package

No data available yet.