https://github.com/phillippbertram/langly
CLI Tool that generates platform specific translation files for Android (xml) & iOS (Localizable.strings) from shared .arb files
https://github.com/phillippbertram/langly
android arb cli cross-platform ios language localizable-strings localization translation xcode
Last synced: 2 months ago
JSON representation
CLI Tool that generates platform specific translation files for Android (xml) & iOS (Localizable.strings) from shared .arb files
- Host: GitHub
- URL: https://github.com/phillippbertram/langly
- Owner: phillippbertram
- License: mit
- Created: 2024-05-16T08:33:42.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-28T12:35:21.000Z (almost 2 years ago)
- Last Synced: 2025-07-15T22:20:52.389Z (8 months ago)
- Topics: android, arb, cli, cross-platform, ios, language, localizable-strings, localization, translation, xcode
- Language: Go
- Homepage:
- Size: 2.75 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# langly
`langly` is a command-line tool written in Go for converting `.arb` files (used in Flutter for localization) into platform-specific formats for iOS and Android. The tool generates `Localizable.strings` and `Localizable.stringsdict` files for iOS, and `strings.xml` files for Android, allowing translations to be managed and utilized in native mobile app projects.
## Features
- Convert `.arb` files to iOS `Localizable.strings`
- Convert `.arb` files to iOS `Localizable.stringsdict` (in `plist` format) for handling plurals
- Convert `.arb` files to Android `strings.xml`
## Installation
To install the tool, you need to have Go installed on your machine. Clone the repository and build the binary:
```sh
git clone https://github.com/phillippbertram/langly.git
cd langly
go build -o langly
```
## Usage
### Convert .arb file to iOS format
To convert an `.arb` file to iOS `Localizable.strings` and `Localizable.stringsdict` files:
```sh
./langly ios examples/arb -o ./examples/ios/langly/langly/Localizations
```
### Convert .arb file to Android format
To convert an `.arb` file to Android `strings.xml` file:
```sh
./langly android examples/arb -o ./examples/android/app/src/main/res
```
## Example
Given an `.arb` file `example_en.arb`:
```json
{
"@@locale": "en",
"app_title": "Fast Shopping",
"@app_title": {
"description": "Shown on top of the screen."
},
"list_item_no_name": "No name",
"@list_item_no_name": {
"description": "When the item has no/empty name."
},
"list_item_done_ago": "done {when}",
"@list_item_done_ago": {
"description": "Small caps date when item was marked as done.",
"placeholders": {
"when": {
"type": "String",
"example": "a minute ago"
}
}
},
"delete_shopping_list_dialog_body": "Do you really want to delete {list_name} shopping list? This operation cannot be undone.",
"@delete_shopping_list_dialog_body": {
"placeholders": {
"list_name": {
"type": "String",
"example": "Groceries"
}
}
},
"nWombats": "{count, plural, =0{no wombats} =1{1 wombat} other{{count} wombats}}",
"@nWombats": {
"description": "A plural message",
"placeholders": {
"count": {
"type": "Int"
}
}
},
"pageHomeInboxCount": "{number, plural, zero{You have no new messages} one{You have 1 new message} other{You have {number} new messages}}",
"@pageHomeInboxCount": {
"description": "New messages number on the Home screen",
"placeholders": {
"number": {}
}
}
}
```
Running the tool for iOS:
```sh
./langly ios ./arb -o ./output
```
This generates `Localizable.strings`:
```plaintext
"app_title"="Fast Shopping";
"delete_shopping_list_dialog_body"="Do you really want to delete %@ shopping list? This operation cannot be undone.";
"list_item_done_ago"="done %@";
"list_item_no_name"="No name";
```
and `Localizable.stringsdict` in the specified output directory:
```xml
nWombats
NSStringLocalizedFormatKey
%#@count@
count
NSStringFormatSpecTypeKey
NSStringPluralRuleType
NSStringFormatValueTypeKey
d
one
1 wombat
other
%d wombats
zero
no wombats
pageHomeInboxCount
NSStringLocalizedFormatKey
%#@number@
number
NSStringFormatSpecTypeKey
NSStringPluralRuleType
NSStringFormatValueTypeKey
d
other
You have %d new messages
```
Running the tool for Android:
```sh
./langly android ./arb -o ./output
```
This generates `strings.xml` in the specified output directory.
```xml
Fast Shopping
Do you really want to delete %s shopping list? This operation cannot be undone.
done %s
No name
%d wombats
no wombats
1 wombat
You have %d new messages
```
## License
This project is licensed under the MIT License - see the LICENSE file for details.
## Contributing
Contributions are welcome! Please open an issue or submit a pull request for any bugs or features.