Localization




CS174

Chris Pollett

April 27, 2016

Outline

Introduction

Buzz-words: i18n and L10n

Unicode

Glyphs, Character Sets, Encodings

More on Code Points, Characters, Glyphs, and Graphemes

Byte-order Mark

UTF-8 Encoding

Let's Build Something

For small projects, one quick and easy way to support multiple languages is an array-based approach. You have an array:

$tl = [
  "locale1" => [
      "msg_id" => "translation"
  ],
  "locale2" => [
  ],
];

Your PHP script determines the locale of the client by looking at the Accept-Language header to determine the most preferred locale, $locale. In views, when there is text that needs to be translated, we have inclusions like: <?= $tl[$locale]['string_to_translate']; ?>.

Test this strategy out, by writing a short PHP program which detects the locale and uses an array like the above to either output "Hello" in English or "Hello" in one of the other languages you have translated this word for.

Post your solutions to the April 27 Class Thread.

Specifying and Handling UTF-8

Text Direction

Text-direction: HTML and CSS