app-localization-cli
v1.0.16
Published
A simple CLI tool for managing app localizations for iOS and Android projects using Capacitor or Cordova.
Maintainers
Readme
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.
- Style Rater: Meet Your Better Self!
- Chinese Meal: Chinese Vegetarian Cuisine Guide.
- Welcome to add your app here...
Installation & Usage
No installation needed! Just run with npx:
npx app-localization-cliOr install globally if you prefer:
npm install -g app-localization-cli
update-localizationsProject 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.xmlConfiguration
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 androidHow It Works
iOS
- Creates
.lprojdirectories for each language - Generates
InfoPlist.stringsfiles with localized values - Updates
Info.plistto add CFBundleLocalizations and CFBundleDevelopmentRegion localizations values - 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
- Creates
values-*directories for each language - Generates or updates
strings.xmlfiles - Preserves existing string resources
- 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
| Key | Description |
| --------------------- | ------------------------ |
| CFBundleDisplayName | App name shown on device |
| ... | Any string resource |
Android
| Key | Description |
| --------------------- | ------------------- |
| title_activity_main | Application title |
| ... | Any string resource |
Language Code Mapping
| Language | iOS Code | Android Code |
| ------------------- | --------- | ------------------------------------------------- |
| English | en | values |
| Simplified Chinese | zh-Hans | values-zh-rCN |
| Traditional Chinese | zh-Hant | values-zh-rTW, values-zh-rHK, values-zh-rMO |
| Other Languages | ... | ... |
Troubleshooting
Common Issues
NSUserTrackingUsageDescription is empty after build
Set a default value for
NSUserTrackingUsageDescriptioninInfo.plist. Otherwise, it will be empty after build inCFBundleDevelopmentRegionlanguage.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/resWrong Directory Structure
# Should be in project root npx app-localization-cli --helpInvalid JSON Format
# Validate JSON files cat localizations/*.json | jq '.'
Debug Mode
# Run with debug output
DEBUG=true npx app-localization-cliLicense
MIT
