Skip to content

Localization guide

RobbWatershed edited this page Mar 27, 2022 · 2 revisions
Hentoid supports different languages and can speak with you in your native one if it's supported. Localizations themselves, though, are done by volunteers, so if you find your language to be unsupported, you can help both yourself and the Hentoid community by contributing to our localization efforts!
You are not required to know Java or Android development if you're implementing support for a language not significantly different from the large European ones at least in terms of script (e.g. Latin, Cyrillic, Greek, possibly other left-to-right scripts) and using Western Arabic numerals ([0..9]). These skills are still beneficial, but they're also important for a more natural way of displaying the app in a "non-standard" locale. Don't fret asking for advice anyway!
If localizing Plug Reactions (array_plug_reactions.xml) and Splash Screen Quotes (array_splash_quotes.xml) isn’t something you want to deal with for any reason — don’t worry, you can omit these and still ask for your localization to be considered finished.
Regardless of the method used to create a new supported locale or improving an existing one, here are some basic string elements you should know how to deal with when making your own strings.

Ways to contribute a translation

Online collaborative translation platform

Currently we're working with Smartcat. Whether you wish to start working on a new language or continuing the existing translation project, hop on to our Discord and ask for the access on the #localization channel!
If no one has ever localized Hentoid to your language before, you'd first need to fill out a glossary (you'll get one on the Discord server); it's a list of terms that should be localized the same way everywhere in the app.
We advise you to sign up on Smartcat beforehand to take the tutorial. Please also note that, unfortunately, Smartcat doesn't have a mobile app, nor is their website optimized for mobiles at all.

smartcat-workspace

After accepting the task, you should see Hentoid's project in your tasks list. Go ahead and open it!

smartcat-project

Under "Tasks" you can now see different groups of strings, such as Splash Screen Quotes, General Strings, Settings, etc. You can open each group individually to continue working, or click a "catch-all" "Continue Translation" button to go straight to the editor.

smartcat-editor

The Smartcat editor is pretty straightforward and looks sort of like Google Docs. You can toggle the right-side and bottom-side panels to assist you with such niceties as glossary terms, previous translations of alike strings, etc.
Note that the Smartcat editor can also be annoying at times, especially with its warnings (yellow exclamation mark signs on the right to such strings) and strings just disappearing from the interface sometimes. Two things to learn before worrying that some thing could be your own error:
  1. Several resource files should not be touched as they’re mistakenly offered for localization. These are: array_url_blacklist.xml, array_url_whitelist.xml, donottranslate.xml.

  2. Think of Smartcat’s warnings as of Microsoft Word spell checker’s ones; i.e. they’re not always particularly helpful (or meaningful). Remember that localizing isn’t about translating verbatim, so each “Translation does not match the glossary term” message, for example, should be looked at individually for each case.

Editing XML resources directly

First order of business — Android Studio is the best editor, simply because of its comprehensive checks and tools to test how the localization would look in a finished product before sending it to the dev team. It's possible to get away with a simple text editor or VS Code even, but that way there's a considerably larger field for mistakes to happen.

studio-side-by-side

There's two ways of making a localization in Android Studio, but which one you should go with is really a question of preference. The first one is simply editing the XML resources manually. You can open other localizations or resources from the same localization in side views to assist yourself.
This is a more advanced option, so if you feel like you need a more streamlined interface, feel free to open the Translations Editor by clicking on "Open editor" on the hint above the text.
To create a new locale, you should create a new resource file — like so:

studio-new-values

And then add the "Locale" qualifier and enter the same file name as the resource file's you're localizing.

studio-new-res

The second way may be more suitable if you don't feel that much comfortable with the Studio yet — the Translations Editor. It essentially hides as much of XML junk as possible, allowing you to select the options you need using intuitive interface.

studio-translations-editor

A new locale can be created by clicking on the globe icon with a "plus" sign at the bottom of it.
After you’ve finished and tested your work, submit a pull request! Your localization will be reviewed and, if everything’s alright, merged into the dev branch so that others could use new locale on the next app update.

Technical (a.k.a. “What are these blue boxes in Smartcat?”)

XML and HTML markup tags:

Used to encapsulate elements mostly for adding style to the text. Syntax: <tag attribute="value" attribute2="value2">String value</tag>
  • <xliff:g> or <x:g>: XLIFF; specifies the meaning and example values for variables used in strings. The meaning is set with the id attribute, and the example value — well, with example! Either of these attributes (even both of them) can be omitted to emphasize the necessity of keeping a certain escape character sequence(s) (more on that later on) intact when translating (e.g. Delete<x:g>\?</x:g>). This particular example escapes only one character though—the question mark—which means that adding this tag only bloats the string. Example use: "Loading image: <x:g id="percentage" example="50%">%d%%</x:g>"
  • <b>: Bold text. Example use: "<b>Hentoid</b> is a Doujinshi &amp; H-Manga archiving app."
  • <i>: Italic text. Example use: "the <i>usual</i> book\?"

Escape sequences:

Used to display a special programming or markup symbol correctly on user's screen, like the question mark (?). Almost all of these are the same symbols just with a backslash prepended (\), but as the percent sign is used to format arguments in strings (like %d for a decimal number or %s for another string), its escape sequence is written as %%.
You do not need to actually know all escape sequences except for \n, a special "new-line" symbol to actually make a new line (because pressing [Enter] in your editor tells Android nothing about the text format) and remembering to escape single and double quotes each with \' and \" respectively. Other than that, you've simply got to memorize the pattern to leave such sequences as is when translating a string with them. See Handle special characters on Android Developers for further reading.
Clone this wiki locally