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
Go の GC の不得意な部分を克服したい
taiyow
3
830
Recoilを剥がしている話
kirik
5
7k
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
590
Security_for_introducing_eBPF
kentatada
0
110
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
350
Beyond ORM
77web
8
1.1k
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
280
useSyncExternalStoreを使いまくる
ssssota
6
1.3k
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
910
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
280
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
44
13k
The Invisible Side of Design
smashingmag
298
50k
How GitHub (no longer) Works
holman
311
140k
Being A Developer After 40
akosma
87
590k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Unsuck your backbone
ammeep
669
57k
Scaling GitHub
holman
459
140k
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