Coder Social home page Coder Social logo

liquidsoul / localizationconverter Goto Github PK

View Code? Open in Web Editor NEW
15.0 4.0 4.0 200 KB

A command-line tool to convert mobile localization files

License: MIT License

Swift 98.11% Makefile 1.87% Ruby 0.02%
localization-tool ios swift android l10n localization

localizationconverter's Introduction

LocalizationConverter

Build Status

A simple command-line tool to convert Android strings.xml files into iOS Localizable.strings and Localizable.stringsdict files.

Installation

The tool can be installed using brew. All you have to do is run the following command:

brew install liquidsoul/formulae/l10nconverter

Usage

You need to pass the action to the tool to execute the conversion or get the usage help:

l10nconverter help

You can convert a android strings directory with this command:

l10nconverter convertAndroidFolder android/ --output=ios/

The tool expects the folder to have the following layout:

android
├── values
│   └── strings.xml
└── values-fr
    └── strings.xml

Which is the standard Android resources layout. See the Android String Resources documentation for more details.

It will output the following folder tree containing iOS localization files:

ios
├── Base.lproj
│   ├── Localizable.strings
│   └── Localizable.stringsdict
└── fr.lproj
    ├── Localizable.strings
    └── Localizable.stringsdict

The presence of stringsdict files will depend on the existance of plurals in your localization. None will be generated if you do not have plurals keys. You can look at the Apple documentation for more information on plurals on iOS.

⚠️ Limitations ⚠️

Development information

The Makefile is the central point to run the different commands for this project.
To setup the dependencies and run the tests:

make install
make test

Note that this assumes that brew is installed.

The project uses the Swift Package Manager so you can use it directly to build and run tests on the project.

To generate a release build:

make release

This will output a binary in the release/ folder of the project.

localizationconverter's People

Contributors

liquidsoul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

localizationconverter's Issues

Keep plurals keys in Localizable.strings

I tried to use swiftgen and it only parses the Localizable.strings file without considering the stringsdict file. However, the LocalizationConverter do not duplicate the plural keys in both file.
Maybe it should have an option to do that, like --keep-plural-keys?

Converter does not support double quotes (") in localized values

Converter does not escape " characters when formatting Localizable.strings files.
Note that there is no error but that the Localizable.strings files cannot be parsed by Xcode when used.
You can check this by running plutil on the file.

Example of incorrectly converted strings.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="double_quoted_value">Click "This"</string>
</resources>

Add --version option

There must be a way to know which version of the tool is installed.
To do this, let's add a --version option which should print the actual version of the tool.
One issue is that there is no version information in the code base right now. The only version information is the release tag added to the git repository and referenced in the brew formula

Code coverage report

Code coverage is generated but it seems like it cannot be gathered by tools like codecov or even slather.
This may be because this project is a OS X Command Line Tool and that it required me to add all the source files to the Unit test target.
I looked at another swift command-line tool SwiftLint to see how they have set up the project and apparently, it's an OS X App from which they extract the executable to use it from the command line.
Maybe it the way to go, maybe not...

Converter fails to parse format tags in Android strings.xml file

Android strings resource can contain format tags <b>, <i> and <u>.
The current implementation fails when one of this tag is used.

Example of strings.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="hello.world">Hello <b><u>world</u></b>!</string>
</string>
</resources>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.