Top Banner
web design for RIGHT-to-LEFT languages Lennart Schoors
58

Web design for right-to-left languages

Jan 18, 2015

Download

Technology

Lennart Schoors

Presented at the first Belgian meetup of Fronteers (http://fronteers.be) these slides delve into web design for right-to-left languages like Arabic and Hebrew. Focussing on all aspects like layout, implementation (HTML, CSS, images, ...) and even content.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Web design for right-to-left languages

web design forRIGHT-to-LEFT

languages

Lennart Schoors

Page 2: Web design for right-to-left languages

Me

.web designer at Netloghttp://www.netlog.com

. blog at http://lensco.be

Page 3: Web design for right-to-left languages

Small rectification

. Languages don't have direction, scripts do.

. scripts: Arabic, Hebrew, Urdu, Syriac, ...

. languages that use these scripts:Arabic, Farsi, Hebrew, Yiddish, Urdu, ...

Page 4: Web design for right-to-left languages

One day ...

“Hey, can you do a quick check to see if our site works in Arabic?”

“Sure thing!”

Page 5: Web design for right-to-left languages

Piece of cake!

http://www.flickr.com/photos/myfrenchcuisine/106124203

Page 6: Web design for right-to-left languages

Instead...

. I spent about 4 weeks doing research

.piecing the puzzle together

. ... without the picture on the box

Page 7: Web design for right-to-left languages

Design

Page 8: Web design for right-to-left languages

main principle

.mirror layout

Page 9: Web design for right-to-left languages
Page 10: Web design for right-to-left languages
Page 11: Web design for right-to-left languages
Page 12: Web design for right-to-left languages
Page 13: Web design for right-to-left languages
Page 14: Web design for right-to-left languages

main principle

.mirror layout

.columns

.navigation

. form fields

.breadcrumbs

.banners

. (Internet Explorer even flips scrollbars)

Page 15: Web design for right-to-left languages
Page 16: Web design for right-to-left languages
Page 17: Web design for right-to-left languages

While unconventional and sometimes even confusing for left-to-right oriented brains, this mirrored layout is what speakers of RTL languages consider ‘correct’.

Page 18: Web design for right-to-left languages

What about ... dates?

dd/mm/yyyy

Although they sometimes have their own calendars, they’re used to western dates.

Page 19: Web design for right-to-left languages

What about ... calendar tables?

Flip it. Monday goes on the right, Sunday on the left. Yeah, I know.

http://drbl.in/17440

Page 20: Web design for right-to-left languages

What about ... HTML editing?

RTL source editing is hell. Best practice is to have a button to switch direction modes.

More on bidi source editing:http://www.sw.it.aoyama.ac.jp/2005/pub/IUC28-bidi/IUC28.html

Page 21: Web design for right-to-left languages

Design

.mirror layout

. some exceptions

.When in doubt, ask a local.

Page 22: Web design for right-to-left languages

Implement

Page 23: Web design for right-to-left languages

Implement: 4 steps

1. dir="rtl"

2. CSS

3. images

4. HTML tweaks

Page 24: Web design for right-to-left languages

<html dir="rtl">

Step 1. HTML direction

. in markup, not CSS

.W3C:“Because it is so closely tied to the content and so necessary to the readability of the document, bidi information should be embedded in the document with the (X)HTML 'dir' attribute.”

Page 25: Web design for right-to-left languages

Step 1. HTML direction

. flips base direction – things like

.default text-align

.page flow (where elements start)

. tables

. for everything else, there's …

Page 26: Web design for right-to-left languages

Step 2. CSS

.manually edit all attributes that have some kind of directionality

margin, padding, text-align, background-position, float, clear, left, right, text-indent, border, border-radius, direction, …

Page 27: Web design for right-to-left languages

Step 2. CSS

. seperate stylesheet, or in existing CSS file combined with class on body

.make it easy for yourself, use classes like:

.left { float: right !important; }

.right { float: left !important; }

.textAlignLeft { text-align: right !important; }

.textAlignRight { text-align: left !important; }

Page 28: Web design for right-to-left languages

RTL CSS issues

.common complaint that text is too small, so bump the body text size

.background-position problems: “3px top” becomes what in RTL context?

.proposals for attributes like margin-start & margin-end

Page 29: Web design for right-to-left languages

RTL browserbugs

.OH YEAH!

.of course, Internet Explorer 6 & 7

.but also Firefox 2 (Gecko 1.8)

. fortunately, most of these bugs are relatively simple to fix

. let’s take a look at some of them ...

Page 30: Web design for right-to-left languages

Firefox 2: margins on list items

Applying a right margin on a list item pushes the item to the right, but not the list bullet. Applying a left margin on a list item doesn’t push the item to the left, only the list bullet.

<ul> <li>foo</li> <li style="margin-right: 20px;">bar</li> <li style="margin-left: 20px;">bar</li></ul>

Page 31: Web design for right-to-left languages

Firefox 2: margins on list items

Applying a right margin on a list item pushes the item to the right, but not the list bullet. Applying a left margin on a list item doesn’t push the item to the left, only the list bullet.

Safari Firefox 2

Page 32: Web design for right-to-left languages

Firefox 2: images start on left side

<div style="width: 200px"> <img src="img.jpg" style="width: 300px" /></div>

Page 33: Web design for right-to-left languages

Firefox 2: images start on left side

Page 34: Web design for right-to-left languages

Firefox 2: images start on left side

Page 35: Web design for right-to-left languages

IE6&7: shifted/disappearing borders

on relative positioned inline elements

fix: trigger hasLayout

<span style="position: relative; border-bottom: 1px solid red;"> This should have a red underline</span>

Safari

IE6&7

Page 36: Web design for right-to-left languages

IE6&7: nested floats

Right floated elements inside floated elements are not rendered

fix: trigger hasLayout

<div style="background: red; float: right;"> <div style="background: yellow; float: right;"> test </div></div>

Safari IE6&7

Page 37: Web design for right-to-left languages

IE6&7: pushy margins bug

Left or right margins on inline elements work correctly on the content, but not on back-grounds. The margin seems to be applied seperately on the background as well.

<div style="background: yellow; margin: 10px;"> div div div div div</div>

<span style="background: lightblue; margin: 10px;"> span span span span</span>

Page 38: Web design for right-to-left languages

IE6&7: pushy margins bug

fix: trigger hasLayout

Safari

IE6&7

Page 39: Web design for right-to-left languages

Browser usage

0%

10%

20%

30%

40%

50%

February March April May June July August September October

IE8 IE7 IE6 Firefox Chrome Safari

ar.netlog.com

Page 40: Web design for right-to-left languages

Octoberar.netlog.com

Page 41: Web design for right-to-left languages

Step 3. images

.mirror arrows, layout images, ...

.avoid text in images

.CSS3 wins (shadows, rounded corners, … less images!)

. sprites win

img.arrowLeft { background-position: 0 -400px; }img.arrowRight { background-position: 0 -384px; }

Page 42: Web design for right-to-left languages

Step 4. HTML tweaks

.directionally neutral characters

.parentheses, numbers, punctuation

.will mess with your text flow, like:

)6 !"#)

. solution: bidirectional override and direction mark characters

http://www.robinlionheart.com/stds/html4/dir.html

Page 43: Web design for right-to-left languages

Bidirectional override <bdo>

The <bdo> tag allows you to specify the text direction and override the bidirectional algorithm

<bdo dir="rtl">foo bar</bdo>

renders like:

rab oof

Page 44: Web design for right-to-left languages

Direction mark characters

. left‐to‐right mark (&lrm;)right‐to‐left mark (&rlm;)

. force the directionality of directionally neutral characters

(2 &lrm;)!"#

({counter_photos} ||pictures||<!-- IF languageDirection=="rtl" -->&lrm;<!-- ENDIF -->)

Page 45: Web design for right-to-left languages

RTL mobile websites?

. lots of mobile use in Middle East, India, …

.Blackberry, Opera Mini

.mobile sites are often rather limited in terms of layout and CSS, so usually few severe issues

. test

Page 46: Web design for right-to-left languages

Content

Page 47: Web design for right-to-left languages

“ethical” concerns

.often muslim countries, with different views on privacy, decency, ...

.moderate your user generated content

Page 48: Web design for right-to-left languages

Netlog logged out homepage

Page 49: Web design for right-to-left languages

Netlog logged out homepage

Page 50: Web design for right-to-left languages

Netlog logged out homepage

Page 51: Web design for right-to-left languages

fromrighttoleft.org

Page 52: Web design for right-to-left languages

so I was frustrated...

. faced with lack of information and resources

. idea: a collaborative platform that centralizes all bits and pieces of information on right to left web development

Page 53: Web design for right-to-left languages

fromrighttoleft.org

. registered domain in september 2008

.was finished for 70%

.but I killed it, because I couldn't invest the time it needed to survive

Page 54: Web design for right-to-left languages
Page 55: Web design for right-to-left languages
Page 56: Web design for right-to-left languages

fromrighttoleft.org

. information is partly outdated

. this presentation is the first step in making the information public

Page 57: Web design for right-to-left languages

RTL web design: roundup

. research (+ ask a local)

.mirror your layout

.adapt your code (CSS, HTML, images)

.adapt your content

. test

Page 58: Web design for right-to-left languages

That’s all folks!

Read on at http://lensco.be

Questions?