๐Ÿ“ Excel to ARB Generator

Tired of manually converting translation spreadsheets into .arb files for your Flutter or Dart projects? This command-line tool automates the process, letting you manage your localization in a simple Excel fileโ€”and generates all the necessary Application Resource Bundle (.arb) files instantly.


๐Ÿš€ How It Works

You provide a link to a specially formatted Excel file, and the tool generates the corresponding .arb files for each language, ready to be used in your application.

Excel File โ†’ excel2arb Tool โ†’ Generated .arb Files

๐Ÿ”ง Prerequisites

Make sure you have the Dart SDK installed.


๐Ÿ“ฆ Installation

Activate the package globally:

dart pub global activate excel2arb

This makes the excel2arb command available globally in your terminal.


๐Ÿ“ Step 1: Format Your Excel Sheet

Create an Excel sheet following these key formatting rules. You can see a full example here.

โœ… Key Formatting Rules

Column Description
Name [name] Required. Used as the JSON key in .arb files.
Language {locale} Required. Columns with language names and 2-letter locale in {}. E.g., English {en}
Remark Optional. Notes or instructions for translators.
Placeholders [placeholders] Optional. JSON object defining placeholders and their types.

๐Ÿงพ Example Excel Layout

Name [name] Description [description] Remark English {en} Myanmar {my} Placeholders [placeholders]
greeting A welcome message Hello, World! แ€™แ€„แ€บแ€นแ€‚แ€œแ€ฌแ€•แ€ซ แ€œแ€ฑแ€ฌแ€€แ€€แ€ผแ€ฎแ€ธ
welcomeUser Welcomes a specific user Keep {} as-is Hello {userName} แ€™แ€„แ€บแ€นแ€‚แ€œแ€ฌแ€•แ€ซ {userName} {"userName": {"type": "String"}}

โš™๏ธ Step 2: Run the Generator

Once your Excel file is published and accessible via URL, run:

โ–ถ๏ธ Basic Usage

excel2arb --excel-url <your-excel-file-url> --output-directory <path-to-output-folder>

If the script isn't found, try:

dart pub global run excel2arb --excel-url <your-excel-file-url> --output-directory <path-to-output-folder>

๐Ÿงฐ Command-Line Options

Flag Alias Description Default
--excel-url -u (Required) Public URL of the Excel file
--sheet-name -s Sheet name to parse Localization
--output-directory -o Directory to save .arb files Current directory
--gen-l10n -g Also generate l10n.yaml config false

๐Ÿ’ก Full Example

excel2arb -u https://example.com/sample.xlsx -s Localization -o output_dir -g true

๐Ÿ’ก Bonus Tip #1: Using Google Sheets

You can use Google Sheets instead of Excel:

  1. Create your spreadsheet in Google Sheets (follow the same format).
  2. Go to File โ†’ Share โ†’ Publish to web.
  3. Under the Link tab, select the specific sheet.
  4. Change format to Microsoft Excel (.xlsx).
  5. Click Publish.
  6. Copy the generated link and use it with --excel-url.

โœ… This gives you a live Excel download link, so your team can collaborate in real-timeโ€”just run the generator when you're ready.


๐Ÿ’ก Bonus Tip #2: Streamline with an IDE Plugin

If you're using Android Studio or any JetBrains IDE, streamline the sync using the Dart Scripts Runner plugin.

๐Ÿ›  Setup

  1. Install Dart Scripts Runner from JetBrains Marketplace.
  2. In pubspec.yaml, add:
scripts:
  sync_localization:
    script: excel2arb -u https://shorturl.at/abcd -o lib/l10n/locales -g true
    description: Sync localization from google sheet
  1. Replace the URL with your actual spreadsheet link.
  2. Now, you can run sync_localization directly from the Dart Scripts tool window in your IDEโ€”just one click!

Dart Scripts Configuration


โœจ Features

  • โœ… Downloads Excel files directly from a URL
  • โœ… Generates .arb files for all languages
  • โœ… Supports custom sheet names
  • โœ… Optionally generates l10n.yaml
  • โœ… Handles placeholders and their types

๐Ÿค Contributing

Contributions are welcome! Feel free to open an issue or submit a PR on the GitHub repo.

Libraries

excel2arb