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
22
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
110
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
バックエンドのためのアプリ内課金入門 (サブスク編)
qnighy
1
210
Azure AI Foundryのご紹介
qt_luigi
1
250
shadcn/uiを使ってReactでの開発を加速させよう!
lef237
0
370
Simple組み合わせ村から大都会Railsにやってきた俺は / Coming to Rails from the Simple
moznion
3
3.5k
2025.01.17_Sansan × DMM.swift
riofujimon
2
640
React 19でお手軽にCSS-in-JSを自作する
yukukotani
5
590
Запуск 1С:УХ в крупном энтерпрайзе: мечта и реальность ПМа
lamodatech
0
980
カンファレンス動画鑑賞会のススメ / Osaka.swift #1
hironytic
0
200
最近のVS Codeで気になるニュース 2025/01
74th
1
230
BEエンジニアがFEの業務をできるようになるまでにやったこと
yoshida_ryushin
0
250
Fixstars高速化コンテスト2024準優勝解法
eijirou
0
200
Package Traits
ikesyo
2
230
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
Practical Orchestrator
shlominoach
186
10k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3.1k
For a Future-Friendly Web
brad_frost
176
9.5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
370
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Producing Creativity
orderedlist
PRO
343
39k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
BBQ
matthewcrist
85
9.4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Fantastic passwords and where to find them - at NoRuKo
philnash
50
3k
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