Created by Mozilla
Slides www.braniecki.net/talks/imug2014/ (zip) (pdf)
are native English speakers?
use software in a non-English locale?
Zibi Braniecki, @zbraniecki
Mozilla L10n Labs, @mozilla_l10n
dated approach
English-centric
key-value pairs
plurals if you're lucky
(if you're a developer)
(if you're a localizer)
(if you're a user)
client-side
isolated
grammar-agnostic
responsive
based on a social contract
<liked "{{ $user.name }} liked your photo.">
<liked[$user.gender] {
feminine: "{{ $user.name }} polubiła twoje zdjęcie.",
masculine: "{{ $user.name }} polubił twoje zdjęcie.",
}>
document.l10n.localize(['hello', 'new'], function(l10n) {
var node = document.querySelector('[l10n-id=hello]');
node.textConent = l10n.entities.hello;
node.classList.remove('hidden');
});
Developers provide important data as context data
L20n always returns strings
Retranslate pieces of UI when something changes
Resource
Locale
Context
Bindings
<h2 l10n-id="hello"></h2>
<hello "Hello, World!">
<hello "Witaj świecie!">
document.l10n.localize(['hello'], function(l10n) {
element.textContent = l10n.entities['hello'].value;
});
<script type="application/l10n-data+json">
{
"user": {
"name": "John",
"gender": "male"
}
}
</script>
<hello "Hello, {{$user.name}}">
<missed[ $missedCalls == 1 ? 'one': 'many' ] {
one: "You have one missed call",
many: "You have {{$missedCalls}} missed calls"
}>
<plural($n) { $n == 1 ? 'one': 'many' }>
<missed[plural($missedCalls)] {
one: "You have one missed call",
many: "You have {{$missedCalls}} missed calls"
}>
@os
@hour
@screen.width
<hello[ @hour < 12 ? 'morning' : 'evening' ] {
'morning': 'Good morning',
'evening': 'Good evening'
}>
<hello[ @screen.width < 640 ? 'short' : 'long' ] {
'short': 'Sound',
'long': 'Sound & Voice Settings'
}>
document.l10n.localize(['hello'], function(l10n) {
element.textContent = l10n.entities['hello'].value;
});
<hello "You have @i18n.formatCurrency($savings)">
<unreadEmails "You have @i18n.formatNumber($unreadEmails)">
<todayIs "Today is @i18n.toLocaleDateString($date)">
We're committed to invest in l10n environments
Release in the coming days
Try it at l20n.org
Fork it at github.com/l20n