VisualEditor/Design/Internationalization requirements

'''This is a work in progress. Even the first chapter is not fully written.'''

This is a draft document of internationalization requirements for the Visual editor.

Requirements for RTL and bidi text are written separately in the Visual editor/Bidirectional text requirements.

General
It is becoming more and more important to use the HTML lang attribute as much as possible. The WebFonts extension uses it to apply the correct font. Firefox uses it to apply correct punctuation style and starting at version 12 it will (probably) use it to apply the correct spelling checker to a textarea. Mobile devices may use it to show the appropriate on-screen keyboard. Machine translation software may use it for correct translations.

In Wikipedia and in other projects text is often written in a mix of languages. For example, an encyclopedic article may be written in English and include names in foreign spelling, quotations of foreign literary works, titles of foreign-language books, etc.

It can be applied to almost any HTML element - the generic  and  , and also  ,   ,  , , ,   , etc.

Current situation
Currently MediaWiki automatically applies the lang attribute to the element.

To indicate elements in other languages it can be applied manually. This is done haphazardly - either using raw HTML tags or templates such as w:en:Template:Lang and its many derivatives, such as w:en:Template:Lang-sl, w:en:Template:Nihongo, s:en:Template:GHGheb etc. Needless to say, in every project they are implemented separately and differently, if at all.

How it should be
It must be possible to specify that the language of the article's content is different from the language of the wiki. This must somewhere in the page properties. The getPageLanguage can be a starting point, but its actual functionality is very limited. The Page Translation feature in the Translate extension applied language metadata to the pages it creates and this functionality could be moved to the core.

It must also be possible to specify the language of parts of the page using a visual dialog, that can also be used for defining fonts and other properties. Obviously, reusing generic HTML abilities would be a good idea.

The language of the currently selected text must be displayed somewhere; since language is not as visually obvious as font weight, it may be displayed on some kind of a status bar. The fact that the language of a part of a page is different can also be indicated by presenting it with a differently colored font or background.

Naturally, the lang attribute value is supposed to be useful not only for displaying, but for editing, too, for example for choosing the right font while the text is being edited.

Relationship with directionality
The HTML standard specifically says that text direction must not be deduced from the value of the lang attribute, so browsers don't do it. It's unfortunate, but that's how it is. The value of lang can be used to apply correct direction to element server-side.

By default, elements with different directionality should be directionally isolated, either using the tag or the "unicode-bidi: isolate" CSS rule.

See also Visual editor/Bidirectional text requirements.

Fonts
Currently, there are three ways to use fonts in the MediaWiki world:
 * For server-side rendering of SVG images, fonts can be installed on the server. For an example, see Bug 16284 - Support Linux Libertine Font for SVG rendering
 * The WebFonts extension can apply fonts according to lang attribute and CSS font-family declaration. It also allows changing the display font of the rendered page. The Universal Language Selector may change its current functionality.
 * MathJax is an externally developed product. It has its own mechanism to deliver fonts for rendering of mathematical symbols.