css & i18n dos and don’ts when styling multilingual websites

21
CSS & i18n dos and don’ts when styling multilingual websites Gunnar Bittersmann brands4friends

Upload: magda

Post on 23-Feb-2016

54 views

Category:

Documents


0 download

DESCRIPTION

CSS & i18n dos and don’ts when styling multilingual websites. Gunnar Bittersmann brands4friends. Road ahead. pitfalls when styling multilingual websites what’s new in CSS 3 what’s not in CSS (yet?). Problem: word length. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CSS & i18n dos and don’ts when styling multilingual websites

CSS & i18ndos and don’ts

when styling multilingual websites

Gunnar Bittersmannbrands4friends

Page 2: CSS & i18n dos and don’ts when styling multilingual websites

Road ahead1. pitfalls when styling multilingual

websites2. what’s new in CSS 33. what’s not in CSS (yet?)

Page 3: CSS & i18n dos and don’ts when styling multilingual websites

Problem: word lengthEinige Sprachen, wie z.B. Deutsch, Finnisch und Niederländisch, verwenden einzelne lange Wörter dafür, was mehrere kürzere Wörter in anderen Sprachen sind.

Aus „Input processing features“ im Englischen wird

im Deutschen. Der englische Text kann einfach auf zwei Zeilen verteilt werden, wenn

„Eingabeverarbeitungsfunktionen“

nur eine geringe Breite zur Verfügung steht, bspw. neben einem Formulareingabefeld, in einer Reihe von Tabs oder Buttons, in schmalen Spalten. Der deutsche Text hingegen wird nicht automatisch umbrochen, was eine Herausforderung für das Layout darstellen kann.

Page 4: CSS & i18n dos and don’ts when styling multilingual websites

Solution: soft hyphensEinige Sprachen, wie z.B. Deutsch, Finnisch und Nieder-ländisch, verwenden einzelne lange Wörter dafür, was mehrere kürzere Wörter in anderen Sprachen sind.

Aus „Input processing features“ im Englischen wird „Eingabe-verarbeitungs-funktionen“ im Deutschen. Der englische Text kanneinfach auf zwei Zeilen

verteilt werden, wenn nur eine geringe Breite zur Verfügung steht, bspw. neben einem Formular-eingabe-feld, in einer Reihe von Tabs oder Buttons, in schmalen Spalten. Der deutsche Text hingegen wird nicht automatisch umbrochen, was eine Heraus-forderung für das Layout darstellen kann.

Setting break points is only feasible for own content, but often content is provided by other departments of the company (CMS) or is user-generated content .

Page 5: CSS & i18n dos and don’ts when styling multilingual websites

Solution: hyphenationEinige Sprachen, wie z.B. Deutsch, Finnisch und Nie-derländisch, verwenden ein-zelne lange Wörter dafür, was mehrere kürzere Wörter in anderen Sprachen sind.

Aus „Input processing fea-tures“ im Englischen wird „Eingabeverarbeitungsfunk-tionen“ im Deutschen. Der englische Text kann einfach

auf zwei Zeilen verteilt wer-den, wenn nur eine geringe Breite zur Verfügung steht, bspw. neben einem Formu-lareingabefeld, in einer Reihe von Tabs oder Buttons, in schmalen Spalten. Der deut-sche Text hingegen wird nicht automatisch umbro-chen, was eine Herausforde-rung für das Layout darstel-len kann.Text language must be labeled correctly, also of

text fragments in different languages

Page 6: CSS & i18n dos and don’ts when styling multilingual websites

German version

Nouns are spelled with a capital letter in German language; transformation to lowercase should not be applied to German text.

Page 7: CSS & i18n dos and don’ts when styling multilingual websites

Corrected German version

Additional German language-specific rule overwrites transformation.

Page 8: CSS & i18n dos and don’ts when styling multilingual websites

German version

Long words may cause short lines or large spaces. Note that there’s enough space between the menu and the sidenote on the right…

Page 9: CSS & i18n dos and don’ts when styling multilingual websites

Ukrainian version

…as the menu needs more height the space between the menu and the sidenote shrinks…

Page 10: CSS & i18n dos and don’ts when styling multilingual websites

Russian version

…as the menu needs even more height the contents overlap.

Page 11: CSS & i18n dos and don’ts when styling multilingual websites

Arabic version

A horizontal scrollbar appears because of content for screenreaders that should be moved to the right out of the viewport on RTL pages.

Page 12: CSS & i18n dos and don’ts when styling multilingual websites

Arabic version

border-bottom-right-radius should be resetted on RTL pages,box-shadow should be a mirrored version of that on LTR pages.

Page 13: CSS & i18n dos and don’ts when styling multilingual websites

Corrected Arabic version

No horizontal scrollbar, border-radius and box-shadow properly set.

Page 14: CSS & i18n dos and don’ts when styling multilingual websites

✗rtl.css:

#wai-start{

left: auto;right: -999px;

}

Separate stylesheets?default.css:

#wai-start {

position: absolute; left: -999px; width: 990px;display: block;

}

Don’t rely on the order of stylesheets being included in HTML files; use more specific selectors

Page 15: CSS & i18n dos and don’ts when styling multilingual websites

✗rtl.css:

[dir="rtl"] #wai-start{

left: auto;right: -999px;

}

Separate stylesheets?default.css:

#wai-start {

position: absolute; left: -999px; width: 990px;display: block;

}

[dir="rtl"] #wai-start{

left: auto;right: -999px;

}

Having all rules in one stylesheet allows to overview corresponding rules at one sight and makes it less likely to forget something on later changes.

Page 16: CSS & i18n dos and don’ts when styling multilingual websites

Dos and don’ts• Do not assume text to fit into a box,

neither of certain width nor of certain height• Set soft hyphens in long compound words

or use hyphenation• Use text effects that are appropriate

for given language• Make sure you flip everything

needed for websites in RTL scripts• Do not use multiple stylesheets

for different languages/scripts/text directions,use one stylesheet (easier to maintain)

Page 17: CSS & i18n dos and don’ts when styling multilingual websites

New in CSS 3 text module• hyphens: auto• text-emphasis-style: sesame• text-justify: inter-ideograph || kashida• text-align: end

might replace:#foo { text-align: right }[dir="rtl"] #foo { text-align: left }

Page 18: CSS & i18n dos and don’ts when styling multilingual websites

:lang(bal), :lang(bqi), :lang(cja), :lang(glk), :lang(ug)

Styling by languagebody{

font-family: Palatino, serif;}

{font-family: "Traditional Arabic", serif;

}

:lang(ar), :lang(fa), :lang(ps), :lang(ur), :lang(az-Arab), :lang(uz-Arab),:script(Arab)

When content in another language written in Arabic script would later be added to a multilingual website, the stylesheet also needs to be changed. That’s not desired, hence it would be useful if there was a :script pseudoclass.

Page 19: CSS & i18n dos and don’ts when styling multilingual websites

Styling by script

Type: language Subtag: ar Description: Arabic Added: 2005-10-16 Suppress-Script: Arab Scope: macrolanguage

<html lang="ar" script="Arab" dir="rtl">

<html lang="az-Arab" script="Arab " dir="rtl ">

The information about the script is already in the language tag: either in the script subtag or in the language subtag.

Page 20: CSS & i18n dos and don’ts when styling multilingual websites

Implementationget language tag

is undefined?

has script subtag?

look up script for language subtag

found?

use this value use default (Latn)

y

y

y

n

n

n

ü

Page 21: CSS & i18n dos and don’ts when styling multilingual websites

Go raibh maith agat

[email protected]://bittersmann.de