Localisation 

Avoiding the pain of

Use UTF-8

안녕하세요 세계

ASCII-compatible

😬 🔥 🐘

Where do you use UTF-8?

In your database

*with MySQL, use utf8mb4 - MySQL’s “utf8” option is not really UTF-8!

In your HTML

<meta charset="utf-8">

In your PHP code

Set a UTF-8 header in the response: header('Content-Type: text/html; charset=utf-8')

In your IDE

Save files with UTF-8 encoding

strlen('🇬🇧'); // 8
mb_strlen('🇬🇧'); // 2

🇬+🇧 = 🇬🇧

Use multibyte functions like mb_strlen() instead of strlen()

Consider using functions like utf8_encode() and htmlspecialchars($str, 0, ‘UTF-8’)

Give your

translations context

{{ trans("Sign up") }}
{{ trans("Name") }}
{{ trans("PERSONAL_NAME") }}
{{ trans("TEAM_NAME") }}

名字

名称

名字

{{ trans("Name") }}

Time zones

Time zones

Use UTC everywhere

* When transferring datetimes as data

Display times in a user's local timezone

Ask for their timezone when they sign up

Don't change date_default_timezone_set() between requests

Guess their timezone based on geolocation data

Let their browser's JavaScript handle it

* Unless the given time needs to be in a specific timezone, eg. conference date in a physical location, then display them there

Links

liamhammett.com

twitter.com/liamhammett

github.com/imliam

l10n.academy

php.net/manual/ref.mbstring.php

zachholman.com/talk/utc-is-enough-for-everyone-right

Made with Slides.com