Skip to content

Curated tool to transform CSV's files into Android and iOS localizable files.

License

Notifications You must be signed in to change notification settings

rentalia/honyaku

Repository files navigation

Honyaku

Crates.io

Honyaku (hon'yaku) suru in japanese means translation or to translate. And we believe it applies to this software, a web application helper to generate Android and iOS translation files (.xml & .strings) using a CSV file as a source.

Right now, we don't support .po files, because we develop this tool to help us in our day to day work (we don't work with .po files), and we thought that maybe as it is, this software could help others in the same quest we fought (making easy translation process), but if lot of people asks for .po support we could add it (or maybe you could added it and make a PR? ;] )

honyaku-2

Installation

This application is a node express-server based application. You will need to install npm.

  1. Download node for your operative system:

    https://nodejs.org/en/download/package-manager/
    
  2. Next, download this project and go to root path, there you'll see a file called express-server.js and package.json (with other files), use the next command to install npm packages:

    sudo npm install
    
  3. Next step is to run express-server using the next command:

     node express-server.js
    

3.1. If you want to edit any JS file, think of using nodemon. Is a utility that will monitor for any changes in your source and automatically restart your server. Perfect for development

    sudo npm install -g nodemon
  1. Open a web browser and type this url:

     http://localhost:3000/
    

Now, if everything goes OK you will be able to see something like the image above

local-1

  1. You need now to select if you will have or will not have plurals:

local-2

  1. If you select NO for plurals and click on process button, you will see a Success! message. Go to Honyaku/download path and select iOS or Android, you'll see the localized files for each language specified in the CSV file converted in .xml for Android and .strings for iOS.

local-3

The Success Message looks like this:

Success

  1. If you select YES for plurals, you must select the base CSV file and the CSV plurals file and click Process button, if everything goes well you will see a success! message. Go to download path and select iOS or Android, you'll see the localized files for each language specified in CSV file there.

Plurals

Success Message looks like this:

Success

This is the path were the iOS files are downloaded

iOS file

This is the path were the Android files are downloaded

Android

CSV File

The CSV file needs to have the next structure: key (lower case) and the short name for each language supported in capital letters, placed in each column of the CSV. The first column should always be the key word, next column should be each of the supported languages in your application.

  • 📄 You can use the Example folder to see how the CSV are constructed.

  • 📝 Also, you can create in path download/Android and download/iOS all the languages that your app will support.

key EN ES
app_string This is a test Esto es una prueba
app_string_more This is other text Este es otro texto

The key word represents the key that your app will use to localize text for each language.

  • Adding variables

As you will probably know, sometimes is necessary to add variables between our text. Honyaku supports this feature, adding a wildcard (double asterisk) inside the localizable text. For example:

Before After
The user is 20 years old The user is **ld** years old
My dog is called: Gandalf My dog is called: **s**
http://es.someURL.com/12 , http://en.someURL.com/13 http://**1s**.someURL.com/**2ld**
  • Data type supported
Type Wildcard
String s
Double d
Long Double ld
Float f
  • Example output
CSV file text Android output iOS output
This application was made with love by **1s**.\n\nTo say thanks or buy them a coffe say something ;). This application was made with love by %1$s.\n\nTo say thanks or buy them a coffe say something ;). "app_thanks" = "This application was made with love byr %1$@.\n\nTo say thanks or buy them a coffe say something ;).";
  • Escape symbols

For now, we are escaping the % symbol. This case is evaluated in the application, but if you need to escape more symbols, please add an issue and we will try to add it.

Symbol Escaping
20% **ld**%

Plurals

You can create a CSV file to process plurals. This is how the structure looks like:

PLS KEY EN ES
app_people one **ld** traveller **ld** viajero
app_people other **ld** travellers **ld** viajeros
app_night one **ld** night **ld** noche
app_night other **ld** nights **ld** noches

You can see all of the rule cases supported for each language in: http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html

Example:

Language Plural Type
ES one y other
EN one y other
IT one y other
PT one y other
FR one y other
CA one , two, few, other
Dutch (NL) one y other
German (DE) one y other
ALL zero

Note:

if you have any errors deploying express-server.js try to kill the process in CLI:

Search for express-server process:

    $:  ps -ef | grep express

Kill the process:

    $:  kill process-number

TO DO

  • Errors control
  • Tests

Author Information

This role was created in 2017 by Sofa E Swidarowicz Andrade, iOS engineer at Rentalia