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
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
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
770
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
nekko cloudにおけるProxmox VE利用事例
irumaru
3
430
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
210
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
270
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
Symfony Mapper Component
soyuka
2
730
Security_for_introducing_eBPF
kentatada
0
110
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
130
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
1
170
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
930
Jakarta EE meets AI
ivargrimstad
0
240
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Writing Fast Ruby
sferik
628
61k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Thoughts on Productivity
jonyablonski
67
4.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Visualization
eitanlees
146
15k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
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