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
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
18
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
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
960
yield再入門 #phpcon
o0h
PRO
0
1.1k
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.8k
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
690
運用ダッシュボードの設計を誰も教えてくれないのだけどみなさんどうしてるんですか? - チームに監視するという文化を根付かせるための第一歩を踏みたい -
satoshi256kbyte
1
130
Google Apps Script で Ruby を動かす
kawahara
0
270
リアルな遅延を測る仕様
kota_yata
1
120
FDEが実現するAI駆動経営の現在地
gonta
2
290
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
160
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
230
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.8k
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
240
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
670
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
990
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
My Coaching Mixtape
mlcsv
0
240
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
340
Embracing the Ebb and Flow
colly
88
5.1k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
170
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