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
[BalkanRuby 2019] Getting ready for I18n, Shopi...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Edouard Chin
May 17, 2019
Programming
280
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
[BalkanRuby 2019] Getting ready for I18n, Shopify case study
Edouard Chin
May 17, 2019
More Decks by Edouard Chin
See All by Edouard Chin
[Ruby Kaigi 2026] Faster Bundler, Happier Developers
edouardchin
0
16
Journey of a complex gem upgrade
edouardchin
0
480
Upgrading Rails at scale. RailsConf 2018
edouardchin
4
1.1k
Other Decks in Programming
See All in Programming
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
110
torikago - Ruby::Boxで照らすモジュラモノリスの実行境界
se4weed
1
220
5分で問診!Composer セキュリティ健康診断
codmoninc
0
690
数百円から始めるRuby電子工作
tarosay
0
110
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
650
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
2.6k
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.4k
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
2
1.1k
AIが無かった頃の素敵な出会いの話
codmoninc
1
270
AIエージェントで 変わるAndroid開発環境
takahirom
2
740
Build-to-own AI: Agentic Development for Humans
inesmontani
PRO
0
110
FDEが実現するAI駆動経営の現在地
gonta
2
230
Featured
See All Featured
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
350
Fireside Chat
paigeccino
42
4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Practical Orchestrator
shlominoach
191
11k
For a Future-Friendly Web
brad_frost
183
10k
Embracing the Ebb and Flow
colly
88
5.1k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
230
YesSQL, Process and Tooling at Scale
rocio
174
15k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
670
Transcript
Hello! Здравейте! Bonjour! ¡hola! Balkan Ruby 2019-05-17
Edouard Chin https://github.com/Edouard-chin @DaroudeDudek
None
None
2,000,000+ LOC 120,000+ Tests Some Ruby Stats Lot of hardcoded
strings
Main location of hard-coded strings • HTML / ERB (Views)
• Ruby (Helpers, Controllers) • Javascript
ui-journey-bar::before { content: 'Next: '; }
Getting ready for internationalization, Shopify's case study Balkan Ruby 2019-05-17
1) Translate your product !"#$%
/“(.*)”/
Detect hard-coded strings visible by the user def my_endpoint if
params['something'] render(plain: 'Hello World!') end end
Stop the bleeding
None
Static code analysis
<html> <body> <%= link_to('Click here', 'https://example.com') %> Hello World! </body>
</html>
ui_flag ui_title ui_content_list ui_banner … …
link_to('Click here', 'https://example.com') content_tag(‘div’, ‘Ask me!’)
None
# @example # # bad # {a:3} # # #
good # {a: 3} class SpaceAfterColon < Cop MSG = 'Space missing after colon.' def on_pair(node) return unless node.colon? colon = node.loc.operator add_offense(…) end # ... end
link_to -> LinkToCop Button -> ButtonCop … …
link_to('My link', 'https://example.com') content_tag('div', 'Hello') Positional arguments
ui_flag(country: 'US', label: 'Make it great again') Keyword arguments
submit(_, data: { confirm: ‘Send!' }, confirm: ‘data’) Options Hash
form_for @book do |f| f.check_box(:paid, {}, 'Yes', 'No') a.check_box('data') end
Blocks
ui_layout do |row| ui_data_table do |table| table.header do |section| section.row
do |row| row.header('Hello') end row.header('data') end end end Nested blocks
class UIRadioButtonHelper < Cop include BlockOutputHelperBehavior UI_HELPER_NAMES = { form_for:
:ui_radio_button } def forbidden_kwarg?(kwarg) %w(label help_text).include?(kwarg) end def argument_check_required?(index) index > 0 end end
form_for :book do |form| form.ui_radio_button( :genre, label: ‘horror', help_text: 'Scary
books’ ) end
def_node_matcher :ui_block_helper, <<-PATTERN (block { (send nil? #ui_helper_method_names ...) (send
(lvar _) #ui_helper_method_names) } (args (arg $_)) $(...)) PATTERN RuboCop NodePattern https://rubocop.readthedocs.io/en/latest/node_pattern/
<html> <body> Hello World! </body> </html>
<html> <style> p { background: white; } </style> </html>
ERB-Lint https://github.com/Shopify/erb-lint
<%= link_to('MyLink', _) %> ERB-Lint link_to('MyLink', _)
ERB-Lint https://github.com/Shopify/erb-lint
None
RuboCop autocorrection
link_to(‘My Link', _) link_to(I18n.t('path.to.file.my_l'), _) en: path: to: file: my_l:
'My Link'
en: path: to: file: my_l: 'My Link %{here}’ link_to("My Link
#{here}", _) link_to(I18n.t('path.to.file.my_l', here: here), _)
<%= I18n.t(:translation_key_html) %> <%= t(:translation_key_html) %>
bin/rubocop -only I18n .
None
Ruby I18n or gettext ?
I18n.t('some.namespace.key') en: some: namespace: key: 'Hello!' "Hello!" Ruby-i18n
"Hello!" _("Hello!") gettext .po/.mo files to store translations
https://github.com/grosser/fast_gettext/blob/ master/Readme.md#comparison
" #
None
Pseudolocalization
Ŵḛḛḅḥṓṓṓṓḳ ṡααṽḛḛḍ ṡṵṵͼͼḛḛṡṡϝṵṵḽḽẏẏ Webhook saved successfully
egg topper Eierschalensollbruchstellenv erursacher
None
https://github.com/Shopify/ pseudolocalization
MySQL character set
“".bytesize => 4
Unicode Basic Multilingual Plane
Utf8mb4
None
Expose your app to UTF8 characters
Translation vs Localization
None
" % May 3, 2019 2019-05-03 03/05/2019 YYYY-MM-DD (ISO 8601)
DD/MM/YYYY
) 2019-03-05 2019-05-03 03-05-2019
1PM VS 13:00
" %
Edouard Chin 902-210 Gloucester Street Ottawa ON K2P 2K4
Edouard Chin Ottawa ON K2P 2K4
Edouard Chin Ottawa K2P 2K4 Canada
"Miss #{last_name} #{first_name} #{apartment} #{street} #{postal_code} #{province}"
… name: 'United States' week_start_day: 'sunday' format: edit: "{firstName}{lastName}_{company}_{address1} _{address2}_{city}_{country}{province}{zip}_{phone}"
show: "{firstName} {lastName}_{company}_{address1} _{address2}_{city} {province} {zip}_{country}_{phone}"
const address = { company: 'Shopify', firstName: '恵⼦子', lastName: '⽥田中',
address1: '⼋八重洲1-5-3', address2: '', city: '⽬目黒区', province: 'JP-13', zip: '100-8994', country: 'JP', phone: '', }; const addressFormatter = new AddressFormatter('ja'); await addressFormatter.format(address); /* => ⽇日本 〒100-8994東京都⽬目黒区⼋八重洲1-5-3 Shopify ⽥田中恵⼦子様 */
https://www.npmjs.com/package/@shopify/address
Edouard Chin https://github.com/Edouard-chin @DaroudeDudek