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
Rails Is Enterprise So You Might Internationali...
Search
David Celis
March 07, 2014
Programming
0
21
Rails Is Enterprise So You Might Internationalise* Your App
* Note the British spelling
David Celis
March 07, 2014
Tweet
Share
More Decks by David Celis
See All by David Celis
From REST to GraphQL: Why a query language is perfect for writing APIs
davidcelis
0
100
Rails Inflections
davidcelis
5
240
Better Git Commit Messages
davidcelis
8
2.5k
github-flow
davidcelis
16
900
Other Decks in Programming
See All in Programming
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
310
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
910
Outline View in SwiftUI
1024jp
1
340
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
270
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
2k
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
1k
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
最新TCAキャッチアップ
0si43
0
200
C++でシェーダを書く
fadis
6
4.1k
Functional Event Sourcing using Sekiban
tomohisa
0
100
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Music & Morning Musume
bryan
46
6.2k
Docker and Python
trallard
40
3.1k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Documentation Writing (for coders)
carmenintech
65
4.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Unsuck your backbone
ammeep
668
57k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Designing for Performance
lara
604
68k
Bash Introduction
62gerente
608
210k
What's in a price? How to price your products and services
michaelherold
243
12k
Transcript
@davidcelis
@davidcelis
Rails is ready
ENTERPRISE
And so you might
INTERNATIONALISE
app your
i18n Cleaner
en: greeting: "hello world"
en: greeting: "hello world" es: greeting: "hola mundo"
<!-- Template --> <h1><%=t :greeting %></h1>
<!-- Template --> <h1><%=t :greeting %></h1> <!-- GET /welcome -->
<h1>hello world</h1>
<!-- GET /welcome?locale=es --> <h1>hola mundo</h1> <!-- Template --> <h1><%=t
:greeting %></h1> <!-- GET /welcome --> <h1>hello world</h1>
What about transliterating COUNTS?
es: datetime: distance_in_words: n_seconds: one: "1 segundo" other: "%{count} segundos"
n_minutes: one: "1 minuto" other: "%{count} minutos" n_hours: one: "1 hora" other: "%{count} horas" n_days: one: "1 día" other: "%{count} días" n_weeks: one: "1 semana" other: "%{count} semanas" n_months: one: "1 mes" other: "%{count} meses" n_years: one: "1 año" other: "%{count} años" en: datetime: distance_in_words: n_seconds: one: "1 second" other: "%{count} seconds" n_minutes: one: "1 minute" other: "%{count} minutes" n_hours: one: "1 hour" other: "%{count} hours" n_days: one: "1 day" other: "%{count} days" n_weeks: one: "1 week" other: "%{count} weeks" n_months: one: "1 month" other: "%{count} months" n_years: one: "1 year" other: "%{count} years"
<!-- Template --> <h1><%=t 'datetime.distance_in_words.n_months', count: 3 %></h1>
<!-- Template --> <h1><%=t 'datetime.distance_in_words.n_months', count: 3 %></h1> <!-- GET
/countdowns/summer-2014 --> <h1>3 months</h1>
<!-- GET /countdowns/summer-2014?locale=es --> <h1>3 meses</h1> <!-- Template --> <h1><%=t
'datetime.distance_in_words.n_months', count: 3 %></h1> <!-- GET /countdowns/summer-2014 --> <h1>3 months</h1>
O… Okay…
O… Okay…
Just pluralize
But… Even in Spanish?
Yes.
Yes.* * Some assembly required
Yes.* * Some assembly required * * Not the language
Yes.* * Some assembly required * * Not the language
Rails 4 Inf lector
ActiveSupport::Inflector.inflections(:es) do |inflect| inflect.plural(/$/, 's') inflect.plural(/([^aeéiou])$/i, '\1es') inflect.plural(/([aeiou]s)$/i, '\1') inflect.plural(/z$/i,
'ces') inflect.plural(/á([sn])$/i, 'a\1es') inflect.plural(/é([sn])$/i, 'e\1es') inflect.plural(/í([sn])$/i, 'i\1es') inflect.plural(/ó([sn])$/i, 'o\1es') inflect.plural(/ú([sn])$/i, 'u\1es') ! inflect.singular(/s$/, '') inflect.singular(/es$/, '') ! inflect.irregular('el', 'los') end
ActiveSupport::Inflector.inflections(:es) do |inflect| inflect.plural(/$/, 's') inflect.plural(/([^aeéiou])$/i, '\1es') inflect.plural(/([aeiou]s)$/i, '\1') inflect.plural(/z$/i,
'ces') inflect.plural(/á([sn])$/i, 'a\1es') inflect.plural(/é([sn])$/i, 'e\1es') inflect.plural(/í([sn])$/i, 'i\1es') inflect.plural(/ó([sn])$/i, 'o\1es') inflect.plural(/ú([sn])$/i, 'u\1es') ! inflect.singular(/s$/, '') inflect.singular(/es$/, '') ! inflect.irregular('el', 'los') end
ActiveSupport::Inflector.inflections(:es) do |inflect| inflect.plural(/$/, 's') inflect.plural(/([^aeéiou])$/i, '\1es') inflect.plural(/([aeiou]s)$/i, '\1') inflect.plural(/z$/i,
'ces') inflect.plural(/á([sn])$/i, 'a\1es') inflect.plural(/é([sn])$/i, 'e\1es') inflect.plural(/í([sn])$/i, 'i\1es') inflect.plural(/ó([sn])$/i, 'o\1es') inflect.plural(/ú([sn])$/i, 'u\1es') ! inflect.singular(/s$/, '') inflect.singular(/es$/, '') ! inflect.irregular('el', 'los') end
en: datetime: second: 'second' minute: 'minute' hour: 'hour' day: 'day'
week: 'week' month: 'month' year: 'year' es: datetime: second: 'segundo' minute: 'minuto' hour: 'hora' day: 'día' week: 'semana' month: 'mes' year: 'año'
<!-- Template --> <p> <%= count %> <%= t('datetime.month').pluralize(count, I18n.locale)
%> <p>
<!-- Template --> <p> <%= count %> <%= t('datetime.month').pluralize(count, I18n.locale)
%> <p> <!-- GET /countdowns/summer-2014 --> <p>3 months</p>
<!-- Template --> <p> <%= count %> <%= t('datetime.month').pluralize(count, I18n.locale)
%> <p> <!-- GET /countdowns/summer-2014?locale=es --> <p>3 meses</p> <!-- GET /countdowns/summer-2014 --> <p>3 months</p>
Inf lector Let the do its job
locales CLEAN
BONUS
gem 'inf lections'
Currently supported Spanish French Kazakh Norwegian Bokmål Turkish
@davidcelis
@davidcelis