Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RAILS + REACTの実際のサービスでの国際化の話
Search
Hiroyuki Shirakawa
June 08, 2017
Programming
720
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RAILS + REACTの実際のサービスでの国際化の話
Hiroyuki Shirakawa
June 08, 2017
Other Decks in Programming
See All in Programming
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
700
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
18
18k
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
220
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
390
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
8.9k
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
150
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
560
Verilogで学ぶCPU自作入門.pdf
uyuki234
8
3.7k
iOSDC2026登壇資料.pdf
riofujimon
0
200
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
150
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
460
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
200
Featured
See All Featured
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
950
エンジニアに許された特別な時間の終わり
watany
109
250k
Making Projects Easy
brettharned
120
6.8k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Abbi's Birthday
coloredviolet
4
10k
Designing Powerful Visuals for Engaging Learning
tmiket
1
580
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Producing Creativity
orderedlist
PRO
348
41k
A better future with KSS
kneath
240
18k
GraphQLとの向き合い方2022年版
quramy
50
15k
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
Transcript
RAILS + REACT shrkw Meguro.rb#3 2017/05/24(Wed)
Viibar Java, Scala, Python Viibar Ruby/Rails
4K
Viibar 35 4K
None
I18N
Rails i18n Rails (I18n) API | Rails svenfuchs/rails-i18n
JS (ES2015, React) I18n.locale
JS (ES2015, REACT)
React React yahoo/react-intl i18next/react-i18next i18next
JS fnando/i18n-js
I18N-JS Rails JSON React
export_i18n_js: false fallbacks: true translations: - file: "app/assets/javascripts/locales/%{locale}.js" only: -
'*.js.*'
locales ja: js: foo: bar: baz
REACT i18n-js translations layout //= require i18n = javascript_include_tag "locales/#{I18n.default_locale}"
- unless I18n.locale == I18n.default_locale = javascript_include_tag "locales/#{I18n.locale}"
React ES2015 I18n.js global.I18n export default global.I18n;
ES2015 i18n
render() { return <div>{I18n.t('js.submit.close')}</div>; }
JSON PRECOMPILE locale json config.middleware.use I18n::JS::Middleware if Rails.env.development?
production assets:precompile sprockets task 'assets:precompile': 'i18n:js:export'
None
None
ja en MissingTranslationData
glebm/i18n-tasks
unused, add-missing, find, remove-unused, normalize, mv missing unused JS
unused #i18n-tasks-use t('activerecord.models.user') # let i18n-tasks know the User.model_name.human
spec CI
it '各locale.yml translation 欠落 ' do count = i18n.missing_keys.count unless
count.zero? missing_list = "以下 locale 未設定 \n" i18n.missing_keys.each do |locale| locale.keys.each do |key| missing_list << "#{locale.key} | #{key}\n" end end fail missing_list end end
None
None
locales YAML JS YAML
YAML ja: # 両方 利用 設定 isomorphic: attributes: car: &isomorphic_attributes_car
tire: # activerecord: attributes: car: <<: *isomorphic_attributes_car loof: 天井 # js: attributes: car:
JSON
I18N.LOCALE
HTTP Accept-Language
before_action :set_locale def set_locale I18n.locale = extract_locale_from_accept_language_header end def extract_locale_from_accept_language_header
request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]\{2\}/).first end
application_controller
: DEVISE Devise::SessionsController flash application_controller class Devise::SessionsController < DeviseController prepend_before_action
:require_no_authentication, only: [:new, prepend_before_action :allow_params_authentication!, only: :create prepend_before_action :verify_signed_out_user, only: :destroy if authenticated && resource = warden.user(resource_name) flash[:alert] = I18n.t("devise.failure.already_authenticated") redirect_to after_sign_in_path_for(resource) end
rails_admin application_controller#set_locale
Rack rack-contrib/locale.rb at master · rack/rack-contrib · GitHub
DB
DB
None