Skip to content

Help localize the Primer on Bezier Curves

Pomax edited this page Oct 28, 2020 · 1 revision

Localization

Localizing content for the Primer is relatively straight forward, and involves editing content as markdown with some extra bits to allow for LaTeX, <graphics-element> tags, and special <div class="..."> ... </div> code.

  1. fork the project,
  2. Each section directory in the ./docs/chapters directory contains a content.en-GB.md file which acts as master English document,
  3. create a file called content.{locale code}.md in the same directory for your locale and language, using as fully qualified LCID code as possible (for instance, Japanese is content.ja-JP.md, Simplified Chinese is content.zh-CN.md, etc.), taking note that the initial two letter language indicated uses lowercase letters, and the second two letter locale code uses uppercase letters.
  4. Translate the English content to your locale!
  5. Form a PR to the Pomax/BezierInfo-2 repository for any translated files you make in this way. But please remember to file one PR per file, not one PR for 40+ files. That way, if you only have time to translate a single chapter: that's fine, we can merge that in!

Localize the templating strings

Don't forget to also localize the templating strings in locale-strings.js.

One-time add a CSS font stack for your language

If you're contributing a completely new language, rather than translating an untranslated chapter for a language that is already partially translated, you will need to add a locale entry to the site CSS, too.

Now, you don't have to do this yourself, feel free to ask me to do this for you instead if you just want to focus on localizing text, but if you feel up to the challenge... some locales can use the same fonts that English uses, while others do not: to deal with this, there is a dedicated fonts.html fragment that contains the font family information for each locale. See if your locale looks right without update that: if it does, hurray! You're done with the CSS part!

If it doesn't look right, you can make a new entry for your locale:

...
{% elif locale == "your-LOCALE" %}

    :root[lang="{{ locale }}"] {
      font-family: ..., Helvetica, Arial, sans-serif;
      font-size: ...;
    }

...

(note that "your-LOCALE" should be your actual locale code, so if you're writing en-GB content, that would be locale == "en-GB", etc.)

The last three entries always need to be there as "absolutely last fallbacks", but you can use any other web-safe font, as well as any font that may legally be used as self-hosted webfont: if you do use one of those, put the font in the ./docs/fonts directory and create a @font-face rule for it:

...
{% elif locale == "your-LOCALE" %}

    @font-face {
      font-family: "My Font Name";
      src: url(./fonts/my-font-name.woff) format("WOFF");
    }

    :root[lang="{{ locale }}"] {
      font-family: "My Font Name", ..., Helvetica, Arial, sans-serif;
      font-size: ...;
    }

...

And you should be good to go. The one tricky part is to find a font-size that makes your chosen font similarly proportioned to the en-GB locale, so you'll want to play around with that a little.

Questions about Localizing?

Please ask any questions relating to localization on the github issue tracker, so that there is a record of the discussion. This keeps all the information in a single, easily found place, where anyone who is interested in localizing the content can look to see if their own question(s) were already covered.

Typographic conventions

  • Don't use spaces or the like to make text "look right" - we'll use appropriate fonts and presentation CSS for each locale to take care of getting the spacing right (in cases where this is insufficient, custom per-locale JavaScript can be written to ensure moderately decent presentation until browser-supported OpenType and the CSS specifications catch up)

Conventions for specific locales

English

English content uses British spelling. There is an en-GB, which also acts as default locale, and there will not be an en-US. I don't see a reason to have multiple localizations for mutually intelligible versions of English. If, however, you want to help localize the content to a specific English-derived creole language, that's totally awesome and I highly encourage you to submit your PRs!

Japanese (ja-JP)

  • no specific policies atm.

Simplified Chinese (zh-CN)

  • no specific policies atm.