language_excel_localization 0.0.4 copy "language_excel_localization: ^0.0.4" to clipboard
language_excel_localization: ^0.0.4 copied to clipboard

A code-generation Flutter localization package that reads an Excel sheet and instantly generates Dart translation files and a reactive UI controller.

language_excel_localization #

A fast, code-generation Flutter localization package that reads an Excel (.xlsx) sheet and instantly generates Dart translation files and a reactive UI controller.

Bridging the gap between translators (who love Excel) and developers (who love code generation).

🚀 Features #

  • Excel to Dart: Automatically generates separate .dart files for every language in your Excel sheet.
  • No Hardcoded Strings: Includes a powerful .tr() extension to translate strings anywhere in your app.
  • Reactive Engine: Built-in ValueNotifier controller that instantly updates the whole app UI when the language is changed.

🛠️ Installation #

Add the package to your pubspec.yaml:

dependencies:
  language_excel_localization: ^0.0.4

🚀 Usage #

1. Initialize the Controller #

In your main.dart, initialize the LocalizationController with the generated translations:

import 'package:flutter/material.dart';
import 'package:language_excel_localization/language_excel_localization.dart';
import 'generated_localization/localization_lookup.dart';

void main() {
  LocalizationController.instance.init(AppTranslations.translations);
  runApp(const MyApp());
}

2. Use in UI #

Use the .tr() extension to translate strings and wrap your widgets in ValueListenableBuilder to make them reactive:

ValueListenableBuilder(
  valueListenable: LocalizationController.instance,
  builder: (context, lang, child) {
    return Text('hello_world'.tr());
  },
)

3. Change Language #

LocalizationController.instance.changeLanguage('spanish');

🚀 The Excel File Details (Rules & Format) #

For the code generator to work correctly, you must follow these exact rules for your Excel file:

  • **File Name: It must be named exactly languages.xlsx.
  • **File Location: Place the file directly inside your project's lib/ folder.
  • **Row 1 (Languages): The very first row MUST contain your language names in lowercase (e.g., english, spanish, hindi).
  • **Column A (Keys): The very first column acts as your translation keys (the base words you will use in your Dart code).

Once your languages.xlsx file is placed inside the lib/ folder, run this exact command in your terminal:

dart run language_excel_localization:generate

When you run the command above, the package reads your Excel sheet and automatically creates a new folder at lib/generated_localization/. Inside, it builds:

  • **localization_lookup.dart: The master configuration file containing AppTranslations.
  • **Modular Language Files: (e.g., english.dart, spanish.dart) containing pure Dart Maps of your translations.
2
likes
160
points
230
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A code-generation Flutter localization package that reads an Excel sheet and instantly generates Dart translation files and a reactive UI controller.

Repository (GitHub)

License

MIT (license)

Dependencies

flutter, path, spreadsheet_decoder

More

Packages that depend on language_excel_localization