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
20
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
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.1k
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.1k
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
890
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
Ethereum_.pdf
nekomatu
0
460
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
890
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Jakarta EE meets AI
ivargrimstad
0
140
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
427
64k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
Bash Introduction
62gerente
608
210k
Gamification - CAS2011
davidbonilla
80
5k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Adopting Sorbet at Scale
ufuk
73
9.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Speed Design
sergeychernyshev
24
610
Faster Mobile Websites
deanohume
305
30k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
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