Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

Internationalization Overview

How Vanilla Breeze follows the language, script, direction and locale of a page, and what is left to you.

The approach

The web platform already knows most of what internationalization needs: the lang and dir attributes, the :lang() and :dir() selectors, logical properties, the Intl formatters and the ruby elements. Vanilla Breeze uses them throughout, so a page changes language when its markup says so and not through a setting in script.

In the demo, the buttons change two attributes on the article and swap in translated text. The typeface, line height, quotation marks, date, number and currency formats and the mirrored layout all follow from those two attributes.

What is handled and what you provide

Area The library handles You provide
Languages and scripts A typeface stack, line height and line-breaking rules for each script; quotation marks for each language; ruby annotation display lang on <html> and on any passage in another language
Direction Layout written with logical properties; icons, markers and arrow keys that follow the direction dir="rtl" where the language is written right to left; <bdi> around text whose direction you do not know
Locale and formatting Dates, numbers, currency and file sizes formatted for the nearest lang; calendars and date pickers in the reader's locale Machine-readable values in <time datetime> and <data value>
Translation An attribute for every string a component generates; a small class for swapping page strings The translations, and translate="no" on text that must stay as written

Where to start

One attribute does most of the work. Set the language of the page, and mark any passage in a different language.

Write language tags in BCP 47 form with hyphens: en-GB, pt-BR, zh-Hant. A screen reader uses the tag to choose a voice, the browser uses it for hyphenation and spell checking, and the library uses it for everything on the pages below.

In this section

Languages and Scripts

Typography per script, quotation marks per language and ruby annotations.

Direction

Right-to-left layout, logical properties and mixed-direction text.

Locale and Formatting

Dates, numbers and currency, how the locale is chosen, and other calendars.

Translation

Translating component strings and page text, and protecting what must not change.

↑