The aim of this document is to provide implementers with a baseline for internationalization.
The current situation
Internationalization is an ongoing process, with browsers offering subpar interoperability (typography, writing modes, etc.), Operating Systems sometimes lacking fonts for some languages, and documentation providing little information on topics of interest to Reading Systems (a11y, settings, etc.).
This could well explain why the most popular Reading Apps tend to implement the least common denominator for all languages, especially when it comes to user settings, and to not support more complex languages implementers either know they can’t support well or are used on smaller markets the app/service is not targeting.
Occasionally, when an app does support a language, it can put some constraints on authors, as there is no other way to make sure the publication will be handled well otherwise e.g. specifying the Hans or Hant script for Chinese (zh).
We can’t overemphasize the importance of the internationalization process though, as the 24 languages we added extend support to 3,049,150,507 speakers, from the 1,150 people speaking Western Canadian Inuktitut, to the 1,200,000,000 speaking Chinese. Implementing right to left scripts will extend support to 411,000,000 native speakers, while vertical writing to at least 130,200,000 – excluding Chinese and Korean.
In total, we can cover the needs of 5,262,900,507 speakers. Credit where credit is due, this wouldn’t have been possible if Operating Systems and browsers didn’t tackle this process upstream, added fonts for those languages and improved support in rendering engines.
What implementers need
Supporting the maximum amount of languages and scripts is a complex process.
As a consequence, work for internationalization should be tackled early, as the changes and adaptations needed will have a significant impact on an existing implementation. It indeed impacts the entire implementation, and not only CSS.
Triggering the correct page-progression-direction
Once the page-progression-direction is defined as rtl, it must be reversed in the app:
- the previous resource (document) is on the right;
- the next resource (document) is on the left.
Navigating the publication should follow this pattern.
Loading the correct styles
Readium CSS provides implementers with specific stylesheets for RTL scripts and CJK (including the Mongolian script), those styles must be loaded accordingly. Otherwise, styles for LTR scripts in the horizontal writing mode will apply.
Guidance can be found in the Injection and Pagination document.
Modifying the UI of the app
Ideally, several parts of the app should be customizable depending on the publication. Another option is implementing the least common denominator for all languages.
All Languages
The list of fonts the app offers to users should be specific to the primary language of the publication, and writing-mode if it applies – Japanese currently.
This means fonts for Latin language can’t be reused for Indic, RTL scripts, CJK, etc.
RTL
Several parts of the UI must follow the direction (rtl) of the primary language:
- the running header (title of the publication or chapter);
- the toc and its entries;
- user settings e.g. text align;
- implementers might want to localize the interface based on the language set at the system level, or at least fall back to English.
Moreover, some user settings should be removed if used (letter- and word-spacing) and another one added (arabic ligatures in ar and fa).
CJK
Although the UI can keep an ltr direction with a horizontal-tb writing mode, some extra attention should be paid:
- make sure the “UI font” can display the characters needed in those languages;
- implementers might want to allow authors to set a
vertical-* writing mode for the navigation document (nav.xhtml);
- implementers might want to localize the interface based on the language set at the system level, or at least fall back to English.
Moreover, some user settings should be removed if used (text-align, hyphens, letter- and word-spacing, number of columns in vertical writing, etc.). See User Prefs for further details.
Internationalize features
Implementers should make sure features like search, highlighting, etc. can work well with bidirectional text and unicode – CJK, especially as some characters change from horizontal to vertical writing modes.
Another issue to take into account is that input methods might not allow users to use some features easily, in which case extended research should be made to check realistic options.
Fonts
Implementers should make sure they offer at least two options: the publisher’s font and the default. If they want to extend the list of fonts they provide for some languages, they should follow guidance in the User Preferences doc.
How authors can help
Authors can help in different ways, from authoring files to giving valuable information we can use to improve the entire Readium CSS project.
Authoring
In some cases, EPUB files themselves will help us improve support tremendously.
The metadata in the OPF file will help us trigger the expected behavior. For instance:
- declaring only one
<dc:language> will help us determine the primary language of the publication;
- if this is not possible, add the primary language as the first
<dc:language> item in the OPF;
- declaring the script e.g.
zh-Hant or mn-Mong will help us trigger the correct writing-mode;
- using the EBPAJ guide meta will help us improve support across platforms.
Setting attributes in each document of the publication will also help us make educated choices and could eventually allow us to handle some edge cases like mixed directions or mixed writing modes. Our aim is obviously not to put the burden on authors there, but collaboration is the only solution to get around those edge cases the EPUB specification doesn’t discuss.
What you can do:
- embed fonts when necessary, so that users have at least two options to choose from in settings and/or proper support of the language;
- set the
xml:lang attribute on html;
- set the
dir attribute on html;
- avoid using the
direction CSS property, as it is now recommended.
Reporting issues
First and foremost, please be assured that we’re as annoyed as you are if there is an issue. It doesn’t mean we don’t care, far from it… it just means we lacked information or misunderstood some requirements when designing Readium CSS. Our goal is to achieve the best support possible, and we know we can’t fulfill it without your expertise.
If you encounter any issue specific to a language or script, do not hesitate to open a new issue in the github repository. A reduced sample will definitely help. Check our guidelines for further details.
The most information we have, the better the fix will be. Please feel free to go into extensive details and provide links, documentation, examples, etc. we can check to get a solid grasp of the issue we have to fix.
Sending feedback
We’re not saying you should implement a support of script yourself if we don’t support it at all or very well, but it is noteworthy that we can’t necessarily get all the details right, especially when we don’t know how to speak and write the language you wish were supported or improved.
If our font-stacks are not good enough, a solider one will help. If we don’t have any font-stack for a language, a basic one will do. Additionally, you can point us to libre/open-source fonts which you think should be recommended to implementers.
If we’ve got something wrong in terms of typography, an example – picture, codepen demo, etc. – will help us see how we got there. Please bear in mind we might be limited by what web browsers can do though, and some issues could be consequently deemed “out of scope.” We will at least do our best to report the issue to whom it may concern whenever possible.
Check our contribution guidelines for further details.
Overarching issues
Implementers should be aware there are overarching issues for which we haven’t reached consensus, or couldn’t discuss yet.
The most important issue, by very far, is that checking the writing-mode at runtime can blow performance in extreme ways. It can indeed take 15 seconds to render some complex XHTML files in vertical-*. Needless to say, this would obviously be worse in terms of UX. And this is the reason why we try to guess the writing-mode from the OPF file.
Longer terms issues include:
- polyfilling
-epub-properties for web apps;
- mixed directions (LTR document in a RTL publication) and mixed writing modes (
horizontal-tb document in a vertical-rl publication);
- support for alternate stylesheets, which is critical if the implementer wants to offer a horizontal/vertical-writing user setting;
- support for
rendition: align-x-center;
- support for
ibooks:respect-image-size-class (gaiji) and ibooks:scroll-axis metadata items (see EPUB Compat doc);
rendition: flow of scrolled-doc.
Out of scope
There are some typography and layout issues which are not the responsibility of apps’ implementers but rendering engines’. Those issues include:
- line-adjustment and justification (RTL and CJK);
- run-in headings (
display: run-in), which is popular in CJK;
ruby and its styling;
bidi;
- Kashida Elongation (Arabic);
- joining forms (Arabic);
- single-letter styling (Arabic).
If those issues arise, please report them to whom it may concern (e.g. Chromium, Firefox, Microsoft, Webkit, etc.). The entire web platform will indeed benefit. You can additionally report the issue to us so that we can document it for other implementers.