1.0.14 β€’ Published 3 months ago

app-localization-cli v1.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

App Localization CLI (ALC)

A simple CLI tool for managing app localizations for iOS and Android projects using Capacitor or Cordova.

Features

πŸ“± iOS & Android Support
πŸ”„ Automatic Resource Updates
🌐 Multiple Language Support
⚑️ Easy to Use

Apps use ALC

  • AcuNote: Acupuncture and Meridian points learning app.
  • W3S: Easy frontend tutorials for beginners.
  • Classical Chinese: Learn Classical Chinese Easily.
  • Welcome to add your app here...

Installation & Usage

No installation needed! Just run with npx:

npx app-localization-cli

Or install globally if you prefer:

npm install -g app-localization-cli
update-localizations

Project Structure

Your project should look like this:

your-project/
β”œβ”€β”€ localizations/          # Your localization configs
β”‚   β”œβ”€β”€ en.json
β”‚   β”œβ”€β”€ zh-Hans.json
β”‚   └── zh-Hant.json
β”œβ”€β”€ ios/                    # iOS project directory
β”‚   └── App/
β”‚       β”œβ”€β”€ App/
β”‚       β”‚   β”œβ”€β”€ Info.plist
β”‚       β”‚   β”œβ”€β”€ en.lproj/
β”‚       β”‚   β”œβ”€β”€ zh-Hans.lproj/
β”‚       β”‚   └── zh-Hant.lproj/
β”‚       └── App.xcodeproj/
β”‚           └── project.pbxproj
└── android/               # Android project directory
    └── app/
        └── src/
            └── main/
                └── res/
                    β”œβ”€β”€ values/
                    β”‚   └── strings.xml
                    β”œβ”€β”€ values-zh-rCN/
                    β”‚   └── strings.xml
                    └── values-zh-rTW/
                        └── strings.xml

Configuration

1. Create Localization Files

Create JSON files in the localizations directory for each language:

πŸ“„ localizations/en.json:

{
  "ios": {
    "CFBundleDisplayName": "My App"
  },
  "android": {
    "title_activity_main": "My App"
  }
}

πŸ“„ localizations/zh-Hans.json:

{
  "ios": {
    "CFBundleDisplayName": "ζˆ‘ηš„εΊ”η”¨"
  },
  "android": {
    "title_activity_main": "ζˆ‘ηš„εΊ”η”¨"
  }
}

2. Run the Tool

# Update both platforms
npx app-localization-cli

# Or update specific platform
npx app-localization-cli --platform ios
npx app-localization-cli --platform android

How It Works

iOS

  1. Creates .lproj directories for each language
  2. Generates InfoPlist.strings files with localized values
  3. Updates Info.plist to add CFBundleLocalizations and CFBundleDevelopmentRegion localizations values
  4. Updates Xcode project configuration to include new languages

Example iOS output:

MyApp/
β”œβ”€β”€ en.lproj/
β”‚   └── InfoPlist.strings     # CFBundleDisplayName = "My App";
β”œβ”€β”€ zh-Hans.lproj/
β”‚   └── InfoPlist.strings     # CFBundleDisplayName = "ζˆ‘ηš„εΊ”η”¨";
└── Info.plist                # CFBundleDisplayName = "My App";

Android

  1. Creates values-* directories for each language
  2. Generates or updates strings.xml files
  3. Preserves existing string resources
  4. Handles XML escaping automatically

Example Android output:

res/
β”œβ”€β”€ values/
β”‚   └── strings.xml          # <string name="title_activity_main">My App</string>
└── values-zh-rCN/
    └── strings.xml          # <string name="title_activity_main">ζˆ‘ηš„εΊ”η”¨</string>

Supported Keys

iOS

KeyDescription
CFBundleDisplayNameApp name shown on device
...Any string resource

Android

KeyDescription
title_activity_mainApplication title
...Any string resource

Language Code Mapping

LanguageiOS CodeAndroid Code
Englishenvalues
Simplified Chinesezh-Hansvalues-zh-rCN
Traditional Chinesezh-Hantvalues-zh-rTW, values-zh-rHK, values-zh-rMO
Other Languages......

Troubleshooting

Common Issues

  1. NSUserTrackingUsageDescription is empty after build

    Set a default value for NSUserTrackingUsageDescription in Info.plist. Otherwise, it will be empty after build in CFBundleDevelopmentRegion language.

  2. Files Not Updated

    # Check if localizations directory exists
    ls localizations/*.json
    
    # Verify file permissions
    ls -l ios/App/App
    ls -l android/app/src/main/res
  3. Wrong Directory Structure

    # Should be in project root
    npx app-localization-cli --help
  4. Invalid JSON Format

    # Validate JSON files
    cat localizations/*.json | jq '.'

Debug Mode

# Run with debug output
DEBUG=true npx app-localization-cli

License

MIT

1.0.14

3 months ago

1.0.13

3 months ago

1.0.11

4 months ago

1.0.10

4 months ago

1.0.12

3 months ago

1.0.9

4 months ago

1.0.8

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago