csv_localizations 0.1.5 copy "csv_localizations: ^0.1.5" to clipboard
csv_localizations: ^0.1.5 copied to clipboard

outdated

Localize your Flutter app using a single CSV file for all languages.

csv_localizations #

Localize your Flutter app using a single CSV file.

A minimal localization package built on LocalizationsDelegate.

Usage #

See example

Install #

Add package to your pubspec.yaml

dependencies:
  csv_localizations:

Add CSV asset file #

Add a CSV translation file as an asset and describe it in your pubspec.yaml

Tip: Create a Spreadsheet via Google docs, then export as CSV

flutter:
  assets:
    - assets/lang.csv
CSV example
key, en, nb
Hi, Hi, Hei
Cheese, Cheese, Ost
my_img,assets/en.png,assets/nb.png

Top row show supported language codes; rows below are localizations.

Left column are keys for localized values.

Note: keys can point to local assets like images etc.

MaterialApp #

Add CsvLocalizationsDelegate to MaterialApp and set supportedLocales using language codes.

MaterialApp(
  localizationsDelegates: [
    ... // global delegates
    CsvLocalizationsDelegate(
      CsvLocalizations(
        assetPath: 'assets/lang.csv',
        supportedLanguageCodes: [ 'en', 'nb', ],
      ),
    ),
  ],
  supportedLocales: [ Locale('en'), Locale('nb'), ],
}

API #

Translate strings using

  CsvLocalizations.of(context).tr('Hi')

or use the simpler String extension method

  'Hi'.tr(context)

Localize an image by pointing to various local assets

  Image.asset('my_img'.tr(context))

Note on iOS #

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

Example:

<key>CFBundleLocalizations</key>
<array>
	<string>en</string>
	<string>nb</string>
</array>
6
likes
0
pub points
77%
popularity

Publisher

verified publisherapptakk.com

Localize your Flutter app using a single CSV file for all languages.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

csv, flutter

More

Packages that depend on csv_localizations