Skip to content

How do I translate Refuge Restrooms.org?

DeeDeeG edited this page Apr 20, 2021 · 5 revisions

The English translation files are finally sorted out, so now is a great time to translate!

Finding your locale code

The first step of translating Refuge Restrooms.org is to find out your locale code. This is a two-letter, or three-letter abbreviation for the language you want to translate. You can find this by searching "[language here] locale code", e.g. "Spanish locale code" in your search engine of choice.

(Some search engines: Google.com, Yahoo.com, Bing.com, DuckDuckGo.com, etc...).

Most locales we can use will be one of the following (from here)

af, ar, az, be, bg, bn, bs, ca, cs, cy, da, de, de-AT, de-CH, de-DE, el, el-CY, en, en-AU, en-CA, en-GB, en-IE, en-IN, en-NZ, en-US, en-ZA, en-CY,eo, es, es-419, es-AR, es-CL, es-CO, es-CR, es-EC, es-ES, es-MX, es-NI, es-PA, es-PE, es-US, es-VE, et, eu, fa, fi, fr, fr-CA, fr-CH, fr-FR, gl, he, hi, hi-IN, hr, hu, id, is, it, it-CH, ja, ka, km, kn, ko, lb, lo, lt, lv, mk, ml, mn, mr-IN, ms, nb, ne, nl, nn, oc, or, pa, pl, pt, pt-BR, rm, ro, ru, sk, sl, sq, sr, sw, ta, te, th, tl, tr, tt, ug, ur, uz, vi, wo, zh-CN, zh-HK, zh-TW, zh-YUE

If your locale code is not listed there, it should be listed here or here.

Adding a folder for your locale

First, you may want to take a look at the existing translation folders for the site. They are in this sub-folder: config/locales.

Once you know the locale code for the language you are adding, you can make a new folder named after that locale code. (For example, to add a folder for Spanish, the locale is es, so you would add an es folder at config/locales/es.)

Putting files in the new folder

You can copy files from whichever existing language you are most comfortable with into your new folder. If you are comfortable with English, please copy the English files, since English is the original language that Refuge's text was written in.

So you would:

  • copy every file (filename.en.yml) from config/locales/en into --> config/locales/[new-locale]

Then for each file,

  • rename from filename.en.yml to filename.[new-locale-code].yml.
  • and change the top line of each file from en: -> [new-locale-code]:.

For example, English to French:

  • splash.en.yml -> splash.fr.yml
  • en: -> fr:

Translating the files

Every line in these files is a "key" and "value" pair.

Each pair is formatted like this: key: "value"

The "key" is on the left of the :, and its "value" is on the right of the :. You don't need to translate the "key," only the "value."

For example, this is a translation for the key "hello", from English to Spanish:

  • hello: "Hello!" --> hello: "¡Hola!"

Quote marks (' and ") in the translation files

  • Quotation marks around text aren't necessary most of the time.
  • If you use an apostrophe ', be careful as it is treated as a single quote mark.
    • Apostrophes ' can be "escaped" with a backslash \, like this: That\'s really cool, isn\'t it?
  • Quote marks inside other quote marks can be written like this: "outer, 'inner'" or like this: 'outer, "inner"'

For full documentation of how to use quote marks in YAML, see this page: https://www.yaml.info/learn/quote.html

What's Next?

Usually, when the translations for a given language are all submitted, we try to get in contact with a second native speaker of the given language, who can then review and make any suggestions or corrections. Once that review is done (and everybody agrees on the translations being correct) then we can accept/merge the translation.

Then we would make a new release of our website when we get a chance, so that the new language is active on our real website.

Official Documentation

If you have deeper questions about how this translation system works, and want to read more about it, here is the official documentation:

Any other questions?

We are here to help if you have any questions. Please post an Issue or Pull Request with the translation you are trying to make, and leave your questions in a comment there. Or you can ask on Slack, if you like.