Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ember, Localization, and You
Search
Colby Ludwig
February 21, 2017
Technology
0
50
Ember, Localization, and You
A guide to love, loss, and localization in Ember.
Presented at a Jobber<>Showbie meetup.
Colby Ludwig
February 21, 2017
Tweet
Share
More Decks by Colby Ludwig
See All by Colby Ludwig
Front-end Testing
cdl
7
280
Putting Mobile First
cdl
4
150
Other Decks in Technology
See All in Technology
Claude Code Actionを使ったコード品質改善の取り組み
potix2
PRO
6
2.6k
無意味な開発生産性の議論から抜け出すための予兆検知とお金とAI
i35_267
0
1.3k
WordPressから ヘッドレスCMSへ! Storyblokへの移行プロセス
nyata
0
340
「良さそう」と「とても良い」の間には 「良さそうだがホンマか」がたくさんある / 2025.07.01 LLM品質Night
smiyawaki0820
1
430
2025-06-26_Lightning_Talk_for_Lightning_Talks
_hashimo2
2
110
Lambda Web Adapterについて自分なりに理解してみた
smt7174
5
140
How Community Opened Global Doors
hiroramos4
PRO
1
130
FOSS4G 2025 KANSAI QGISで点群データをいろいろしてみた
kou_kita
0
260
なぜ私はいま、ここにいるのか? #もがく中堅デザイナー #プロダクトデザイナー
bengo4com
0
1.3k
250627 関西Ruby会議08 前夜祭 RejectKaigi「DJ on Ruby Ver.0.1」
msykd
PRO
2
370
「Chatwork」の認証基盤の移行とログ活用によるプロダクト改善
kubell_hr
1
240
開発生産性を組織全体の「生産性」へ! 部門間連携の壁を越える実践的ステップ
sudo5in5k
0
510
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
94
6.1k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Building Applications with DynamoDB
mza
95
6.5k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
800
Code Reviewing Like a Champion
maltzj
524
40k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Optimizing for Happiness
mojombo
379
70k
How STYLIGHT went responsive
nonsquared
100
5.6k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Transcript
None
Ember, Localization and You A guide to love, loss, and
localization.
None
None
None
Static strings Dynamic strings strings with dynamic content Dynamic, pluralized
strings strings with dynamic content that effects pluralization Doesn’t need to be translated user input, variable data, etc
Static strings Dynamic strings strings with dynamic content Dynamic, pluralized
strings strings with dynamic content that effects pluralization Doesn’t need to be translated user input, straight-up numbers, etc - Class Discussion - no due date - Home - Groups - Students
Dynamic, pluralized strings strings with dynamic content that effects pluralization
Doesn’t need to be translated user input, straight-up numbers, etc - Due February 24 at 4:00PM Dynamic strings strings with dynamic content
Dynamic, pluralized strings strings with dynamic content that effects pluralization
Doesn’t need to be translated user input, straight-up numbers, etc - Due February 24 at 4:00PM Dynamic strings strings with dynamic content
Doesn’t need to be translated user input, straight-up numbers, etc
- 33 posts Dynamic, pluralized strings strings with dynamic content that effects pluralization
Doesn’t need to be translated user input, straight-up numbers, etc
Class Discussion
Class Discussion Ϋϥε σΟεΧογϣϯ
Class Discussion Discussion de classe
Class Discussion Klassdiskussion
How?
How?
ember-i18n ember-intl ember-l10n
ember-i18n ember-intl ember-l10n
cd foobar-app/ ember install ember-i18n
ember-i18n adds a few things… A locale generator ember generate
locale en An i18n service Ember.inject.service(‘i18n’) A {{t}} helper {{t ‘foobar’}}
ember-i18n adds a few things… A locale generator ember generate
locale en An i18n service Ember.inject.service(‘i18n’) A {{t}} helper {{t ‘foobar’}}
ember generate locale en
app/locales/ app/locales/en/ app/locales/en/translations.js app/locales/en/config.js
app/locales/en/config.js app/locales/en/ app/locales/ app/locales/en/translations.js
app/locales/en/translations.js export default { // "some.translation.key": "Text for some.translation.key", //
// "a": { // "nested": { // "key": "Text for a.nested.key" // } // }, // // "key.with.interpolation": "Text with {{anInterpolation}}" };
Static strings? no due date Class Discussion Home Groups Students
app/locales/en/translations.js export default { "Class Discussion": "Class Discussion", "no due
date": "no due date", "Home": "Home", "Groups": "Groups", "Students": "Students" };
some template ... {{#link-to ‘classes.show.discussion’ class}} {{t ‘Class Discussion’}} {{/link-to}}
{{#unless assignment.hasDueDate}} {{t ‘no due date’}} {{/unless}} no due date Class Discussion
Dynamic strings? Due February 24 Hello, Jobber!
app/locales/en/translations.js export default { "Class Discussion": "Class Discussion", "no due
date": "no due date", "Home": "Home", "Groups": "Groups", "Students": “Students”, "Due {{date}}": "Due {{date}}" };
some template ... {{t ‘Due {{date}}’ date=date}} Due February 24
{{! -- pretend ‘date’ is ‘February 24’ --}}
Pluralized, dynamic strings? 27 students 1 post 12 files
1 post
1 post 27 posts
1 post 27 posts one (1) other (2, 10, 20)
count
app/locales/en/translations.js export default { // ... "{{count}} posts": { "one":
"one post", "other": "{{count}} posts" } };
some template ... {{t ‘{{count}} posts’ count=10}} 10 posts {{t
‘{{count}} posts’ count=1}} one post {{t ‘{{count}} posts’ count=0}} 0 posts
some template ... {{t ‘{{count}} posts’ count=10}} 10 posts {{t
‘{{count}} posts’ count=1}} one post {{t ‘{{count}} posts’ count=0}} 0 posts
✅ Static strings ✅ Dynamic strings ✅ Static, pluralized strings
❗ Set up default locale
config/environment.js module.exports = function(environment) { var ENV = { //
... i18n: { defaultLocale: 'en' } }; // ... };
✅ Setting up templates to use t helper ✅ Defining
base strings ✅ Setting up ember-i18n’s default locale ❗Defining the other locales
ember generate locale fr
app/locales/fr/translations.js export default { "Class Discussion": "Discussion de classe", "no
due date": "aucune échéance", "Home": "Accueil", "Groups": "Groupes", "Students": "Élèves", "Due {{date}}": "Dû le {{date}}", "{{count}} posts": { "one": "{{count}} publication", "other": "{{count}} publications" } };
Switch the user to another locale? i18n service! Ember.inject.service(‘i18n’)
app/components/locale-switcher/component.js export default Ember.Component.extend({ i18n: inject.service(), // ... localeChanged(newLocale) {
set(this, 'i18n.locale', newLocale); }) });
So that’s the bulk of it.
✅ Defined translations ✅ Used in templates ✅ Change locale
on the fly
❗But there are a ton of gotchas.
Due {{date}} February 24 ✅ tomorrow? ✅
Inlämningsdatum {{date}} February 24? tomorrow?
computed(function() { return ‘some string’; }) Salut, {{name}} ! Welcome,
<span {{action ‘foo’}}>{{name}}! </span>
None
None
None
None
Right-to-left languages???? Non-English numbers? Date formats?
Lesson one. Localization is hard.
Lesson one. Localization is hard way more complicated than you
expect it to be.
Lesson two. Do your localization from the start. (Or at
least as early as possible.)
None
Lesson three. Don’t reinvent the wheel. Please.
Some tips!
1. Use Moment.js for date formatting. (And everything else when
it comes to dates. It’s so so so good.
2. Don’t concatenate or compose translated strings. Concatenation loses context,
which’ll just frustrate users. 42 students submitted homework
2. Don’t concatenate or compose translated strings. Concatenation loses context,
which’ll just frustrate users. 42 homework students submitted
3. Use a translation service to manage strings! There are
so many out there.
Questions?