Skip to content

prongbang/localizegen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

63 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

localizegen 🌍

Generate localization files for mobile applications (Android, iOS, Flutter) from Google Sheets.

Homebrew Platform License: MIT Go Version

   __              ___                     
  / /__  _______ _/ (_)__ ___ ___ ____ ___ 
 / / _ \/ __/ _ `/ / /_ // -_) _ `/ -_) _ \
/_/\___/\__/\_,_/_/_//__/\__/\_, /\__/_//_/
                            /___/          
--> START
# Platform: ios
# Language: en
# Generate: localization
> Create ./App/Locallization/Translate.swift -> Success
> Create ./App/Locallization/en.lproj/Localizable.strings -> Success
<-- DONE

✨ Features

  • πŸš€ Multi-Platform Support - Generate localization files for Android, iOS, and Flutter
  • πŸ“Š Google Sheets Integration - Manage translations in a familiar spreadsheet interface
  • 🌐 Multiple Languages - Support for unlimited languages and locales
  • πŸ”„ Automatic Generation - Generate all language files with a single command
  • πŸ› οΈ Customizable Output - Configure target paths and filenames
  • ⚑ Fast and Efficient - Quick generation with minimal configuration

πŸ“¦ Installation

Via Homebrew (Recommended)

brew update
brew tap prongbang/homebrew-formulae
brew install localizegen

Via Go

go install github.com/prongbang/localizegen

Binary Downloads

Download the latest binary for your platform:

πŸš€ Quick Start

1. Setup Google Sheet

Create a Google Sheet with your translations:

Localize Sheet Example

Structure your sheet with:

  • Column A: Keys (identifiers)
  • Column B+: Translations for each language

2. Extract Sheet IDs

From your Google Sheet URL, extract the DocumentId and SheetId:

https://docs.google.com/spreadsheets/d/<DocumentId>/edit#gid=<SheetId>

Example:

https://docs.google.com/spreadsheets/d/1r91ECV-As0XtuqGKXU7dXnoY4og9XPBoCqwRcdio6EU/edit#gid=0
  • DocumentId: 1r91ECV-As0XtuqGKXU7dXnoY4og9XPBoCqwRcdio6EU
  • SheetId: 0

3. Generate Localization Files

Choose your platform and run the appropriate command:

πŸ€– Android

Generate all languages:

localizegen -platform android \
            -target ./app/src/main/res \
            -document YOUR_DOCUMENT_ID \
            -sheet YOUR_SHEET_ID

Generate specific language:

localizegen -platform android \
            -target ./app/src/main/res \
            -locale en \
            -document YOUR_DOCUMENT_ID \
            -sheet YOUR_SHEET_ID

🍎 iOS

Generate all languages:

localizegen -platform ios \
            -target ./ProjectName/Localization \
            -document YOUR_DOCUMENT_ID \
            -sheet YOUR_SHEET_ID

Generate specific language:

localizegen -platform ios \
            -target ./ProjectName/Localization \
            -locale en \
            -document YOUR_DOCUMENT_ID \
            -sheet YOUR_SHEET_ID

πŸ¦‹ Flutter

Generate all languages:

localizegen -platform flutter \
            -target ./lib/l10n \
            -document YOUR_DOCUMENT_ID \
            -sheet YOUR_SHEET_ID

βš™οΈ Command Options

Flag Description Required
-platform Target platform (android, ios, flutter) βœ…
-document Google Sheet document ID βœ…
-sheet Google Sheet tab ID βœ…
-target Output directory path ❌
-locale Specific language code (e.g., en, th) ❌
-filename Custom output filename ❌

πŸ“ Output Structure

Android

android/
 β”œβ”€β”€ values/
 β”‚   └── strings.xml
 β”œβ”€β”€ values-de/
 β”‚   └── strings.xml
 β”œβ”€β”€ values-es/
 β”‚   └── strings.xml
 └── ...

iOS

ios/
 β”œβ”€β”€ Localizables.swift
 β”œβ”€β”€ de.lproj/
 β”‚   └── Localizable.strings
 β”œβ”€β”€ en.lproj/
 β”‚   └── Localizable.strings
 └── ...

Flutter

flutter/
 β”œβ”€β”€ keys_localizations.dart
 └── sources_localizations.dart

πŸ’‘ Examples

Complete Android Project Setup

# Navigate to your Android project
cd MyAndroidApp

# Generate all localizations
localizegen -platform android \
            -target ./app/src/main/res \
            -document 1r91ECV-As0XtuqGKXU7dXnoY4og9XPBoCqwRcdio6EU \
            -sheet 0

iOS with Custom Path

# Generate iOS localizations with custom path
localizegen -platform ios \
            -target ./MyApp/Resources/Localizations \
            -document YOUR_DOCUMENT_ID \
            -sheet YOUR_SHEET_ID

Flutter Single Language

# Generate only English for Flutter
localizegen -platform flutter \
            -target ./lib/l10n \
            -locale en \
            -document YOUR_DOCUMENT_ID \
            -sheet YOUR_SHEET_ID

πŸ”§ Troubleshooting

Common Issues

  1. Permission Denied: Make sure your Google Sheet is publicly accessible
  2. Invalid Sheet ID: Double-check the extracted DocumentId and SheetId
  3. Missing Dependencies: Ensure Go is properly installed for source installation

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ’– Support

If you find this tool helpful, please consider buying me a coffee:

"Buy Me A Coffee"