sheet_loader_localization 0.6.0 copy "sheet_loader_localization: ^0.6.0" to clipboard
sheet_loader_localization: ^0.6.0 copied to clipboard

Download an CSV file and generates the localization keys from an online Google Sheet.

sheet_loader_localization #

Sheet Localization Generator #

Download a CSV file and generate localization keys from an online Google Sheet to work with easy_localization and easy_localization_loader.

This tool is inspired by flutter_sheet_localization_generator and the original author RinLV.

🔩 Installation #

Add to your pubspec.yaml:

dependencies:
  easy_localization: <latest_version>
  easy_localization_loader: <latest_version>

dev_dependencies:
  build_runner: <latest_version>
  sheet_loader_localization: <latest_version>

🔌 Usage #

1. Create a CSV Google Sheet

Create a sheet with your translations (follow the format below; example sheet here):

CSV example

2. Share the Sheet

There are two options:

  • If your Google Sheet is public, keep the setup as-is.

  • If your Google Sheet is private, follow these steps:

    1. Enable Google Drive API and Generate an API Key
      Follow this guide: How to Use Google Drive API and Get an API Key

    2. Set the apiKey parameter in the @SheetLocalization annotation.


3. Declare the Localization Delegate

Create a Dart file (lib/utils/multi-languages/locale_keys.dart) with the following content:

import 'dart:ui';
import 'package:sheet_loader_localization/sheet_loader_localization.dart';

part 'locale_keys.g.dart';

@SheetLocalization(
  docId: 'DOCID',
  version: 1,
  outDir: 'resources/langs',
  outName: 'langs.csv',
  preservedKeywords: [],
  // OPTIONAL: Only required if your sheet is private
  apiKey: 'YOUR_GOOGLE_API_KEY',
)
class _LocaleKeys {}

4. Generate the Localizations

Run the command below to generate the localization file:

flutter pub run build_runner build
# or
flutter pub run build_runner build --delete-conflicting-outputs

5. Configure Your App

Follow the setup guide from the easy_localization README.


⚡ Regeneration #

To force regeneration of the CSV and localization files (due to caching), simply increment the version field in @SheetLocalization and rerun the build command.


❓ Why This Tool? #

easy_localization supports code generation, but not directly from Google Sheets. This tool simplifies localization workflows by using Google Sheets (ideal for collaboration with non-devs) and supports Flutter null safety.

13
likes
130
points
295
downloads

Publisher

unverified uploader

Weekly Downloads

Download an CSV file and generates the localization keys from an online Google Sheet.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

analyzer, build, build_config, csv, file, flutter, http, intl, path, pub_semver, source_gen

More

Packages that depend on sheet_loader_localization