Set up i18n-js to work with Webpacker

This commit is contained in:
Andreas Nedbal 2020-12-25 15:07:47 +01:00 committed by Andreas Nedbal
parent aac98bd3b2
commit 61f60717fc
10 changed files with 1144 additions and 38 deletions

1
.gitignore vendored
View File

@ -25,6 +25,7 @@ coverage/
# dont push generated js translations to repository # dont push generated js translations to repository
/app/assets/javascripts/i18n/*.js /app/assets/javascripts/i18n/*.js
/app/javascript/packs/legacy/i18n.js
# every fucking time, dolphin # every fucking time, dolphin
.directory .directory

View File

@ -4,7 +4,7 @@ source 'https://rubygems.org'
gem 'rails', '~> 5.2' gem 'rails', '~> 5.2'
gem 'rails-i18n', '~> 5.0' gem 'rails-i18n', '~> 5.0'
gem 'i18n-js', '= 3.0.0.rc10' gem 'i18n-js', '= 3.6'
gem 'pg' gem 'pg'

View File

@ -59,7 +59,7 @@ GEM
erubi (~> 1.4) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3) rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_model_otp (2.0.1) active_model_otp (2.1.0)
activemodel activemodel
rotp (~> 5.0.0) rotp (~> 5.0.0)
activejob (5.2.4.4) activejob (5.2.4.4)
@ -88,7 +88,7 @@ GEM
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0) arel (9.0.0)
ast (2.4.1) ast (2.4.1)
autoprefixer-rails (9.8.5) autoprefixer-rails (10.1.0.0)
execjs execjs
bcrypt (3.1.16) bcrypt (3.1.16)
better_errors (2.9.1) better_errors (2.9.1)
@ -109,11 +109,11 @@ GEM
bootstrap_form (4.5.0) bootstrap_form (4.5.0)
actionpack (>= 5.2) actionpack (>= 5.2)
activemodel (>= 5.2) activemodel (>= 5.2)
brakeman (4.10.0) brakeman (4.10.1)
buftok (0.2.0) buftok (0.2.0)
builder (3.2.4) builder (3.2.4)
byebug (11.1.3) byebug (11.1.3)
capybara (3.33.0) capybara (3.34.0)
addressable addressable
mini_mime (>= 0.1.3) mini_mime (>= 0.1.3)
nokogiri (~> 1.8) nokogiri (~> 1.8)
@ -128,7 +128,7 @@ GEM
image_processing (~> 1.1) image_processing (~> 1.1)
mimemagic (>= 0.3.0) mimemagic (>= 0.3.0)
mini_mime (>= 0.1.3) mini_mime (>= 0.1.3)
chunky_png (1.3.14) chunky_png (1.3.15)
cliver (0.3.2) cliver (0.3.2)
coderay (1.1.3) coderay (1.1.3)
coffee-rails (4.2.2) coffee-rails (4.2.2)
@ -156,12 +156,12 @@ GEM
devise-i18n (1.9.2) devise-i18n (1.9.2)
devise (>= 4.7.1) devise (>= 4.7.1)
diff-lcs (1.4.4) diff-lcs (1.4.4)
docile (1.3.2) docile (1.3.4)
domain_name (0.5.20190701) domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0) unf (>= 0.0.5, < 1.0.0)
equalizer (0.0.11) equalizer (0.0.11)
erubi (1.10.0) erubi (1.10.0)
excon (0.78.0) excon (0.78.1)
execjs (2.7.0) execjs (2.7.0)
factory_bot (6.1.0) factory_bot (6.1.0)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
@ -171,18 +171,18 @@ GEM
fake_email_validator (1.0.11) fake_email_validator (1.0.11)
activemodel activemodel
mail mail
faker (2.2.1) faker (2.15.1)
i18n (>= 0.8) i18n (>= 1.6, < 2)
faraday (1.1.0) faraday (1.2.0)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
ruby2_keywords ruby2_keywords
faraday_middleware (1.0.0) faraday_middleware (1.0.0)
faraday (~> 1.0) faraday (~> 1.0)
ffi (1.13.1) ffi (1.14.2)
ffi-compiler (1.0.1) ffi-compiler (1.0.1)
ffi (>= 1.0.0) ffi (>= 1.0.0)
rake rake
fog-aws (3.6.7) fog-aws (3.7.0)
fog-core (~> 2.1) fog-core (~> 2.1)
fog-json (~> 1.1) fog-json (~> 1.1)
fog-xml (~> 0.1) fog-xml (~> 0.1)
@ -221,7 +221,7 @@ GEM
guard (>= 2.0.0) guard (>= 2.0.0)
guard-compat (~> 1.0) guard-compat (~> 1.0)
guard-compat (1.2.1) guard-compat (1.2.1)
haml (5.2.0) haml (5.2.1)
temple (>= 0.8.0) temple (>= 0.8.0)
tilt tilt
haml_lint (0.36.0) haml_lint (0.36.0)
@ -245,10 +245,10 @@ GEM
httparty (0.18.1) httparty (0.18.1)
mime-types (~> 3.0) mime-types (~> 3.0)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
i18n (0.9.5) i18n (1.8.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
i18n-js (3.0.0.rc10) i18n-js (3.6.0)
i18n (~> 0.6) i18n (>= 0.6.6)
image_processing (1.12.1) image_processing (1.12.1)
mini_magick (>= 4.9.5, < 5) mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3) ruby-vips (>= 2.0.17, < 3)
@ -267,7 +267,7 @@ GEM
turbolinks turbolinks
jquery-ui-rails (6.0.1) jquery-ui-rails (6.0.1)
railties (>= 3.2.16) railties (>= 3.2.16)
json (2.3.1) json (2.5.1)
kaminari (1.2.1) kaminari (1.2.1)
activesupport (>= 4.1.0) activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.1) kaminari-actionview (= 1.2.1)
@ -284,10 +284,10 @@ GEM
addressable (~> 2.7) addressable (~> 2.7)
letter_opener (1.7.0) letter_opener (1.7.0)
launchy (~> 2.2) launchy (~> 2.2)
listen (3.3.1) listen (3.3.3)
rb-fsevent (~> 0.10, >= 0.10.3) rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10) rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.7.0) loofah (2.8.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
lumberjack (1.2.8) lumberjack (1.2.8)
@ -316,11 +316,11 @@ GEM
naught (1.1.0) naught (1.1.0)
nenv (0.3.0) nenv (0.3.0)
nested_form (0.3.2) nested_form (0.3.2)
newrelic_rpm (6.13.1) newrelic_rpm (6.14.0)
nio4r (2.5.4) nio4r (2.5.4)
nokogiri (1.10.10) nokogiri (1.10.10)
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
nokogumbo (2.0.2) nokogumbo (2.0.4)
nokogiri (~> 1.8, >= 1.8.4) nokogiri (~> 1.8, >= 1.8.4)
notiffany (0.1.3) notiffany (0.1.3)
nenv (~> 0.1) nenv (~> 0.1)
@ -340,11 +340,11 @@ GEM
omniauth-oauth (~> 1.1) omniauth-oauth (~> 1.1)
rack rack
orm_adapter (0.5.0) orm_adapter (0.5.0)
parallel (1.20.0) parallel (1.20.1)
parser (2.7.2.0) parser (2.7.2.0)
ast (~> 2.4.1) ast (~> 2.4.1)
pg (1.2.3) pg (1.2.3)
pghero (2.7.2) pghero (2.7.3)
activerecord (>= 5) activerecord (>= 5)
poltergeist (1.18.1) poltergeist (1.18.1)
capybara (>= 2.1, < 4) capybara (>= 2.1, < 4)
@ -355,7 +355,7 @@ GEM
coderay (~> 1.1) coderay (~> 1.1)
method_source (~> 1.0) method_source (~> 1.0)
public_suffix (4.0.6) public_suffix (4.0.6)
puma (5.0.4) puma (5.1.1)
nio4r (~> 2.0) nio4r (~> 2.0)
rack (2.2.3) rack (2.2.3)
rack-pjax (1.1.0) rack-pjax (1.1.0)
@ -414,11 +414,11 @@ GEM
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0) thor (>= 0.19.0, < 2.0)
rainbow (3.0.0) rainbow (3.0.0)
rake (13.0.1) rake (13.0.3)
rb-fsevent (0.10.4) rb-fsevent (0.10.4)
rb-inotify (0.10.1) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
redcarpet (3.5.0) redcarpet (3.5.1)
redis (4.1.4) redis (4.1.4)
regexp_parser (1.8.2) regexp_parser (1.8.2)
remotipart (1.4.4) remotipart (1.4.4)
@ -456,16 +456,16 @@ GEM
rspec-core (~> 3.0, >= 3.0.0) rspec-core (~> 3.0, >= 3.0.0)
sidekiq (>= 2.4.0) sidekiq (>= 2.4.0)
rspec-support (3.9.4) rspec-support (3.9.4)
rubocop (1.3.1) rubocop (1.7.0)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 2.7.1.5) parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8) regexp_parser (>= 1.8, < 3.0)
rexml rexml
rubocop-ast (>= 1.1.1) rubocop-ast (>= 1.2.0, < 2.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0) unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.1.1) rubocop-ast (1.3.0)
parser (>= 2.7.1.5) parser (>= 2.7.1.5)
ruby-progressbar (1.10.1) ruby-progressbar (1.10.1)
ruby-vips (2.0.17) ruby-vips (2.0.17)
@ -502,15 +502,17 @@ GEM
rack-protection (>= 1.5.0) rack-protection (>= 1.5.0)
redis (>= 3.3.5, < 4.2) redis (>= 3.3.5, < 4.2)
simple_oauth (0.3.1) simple_oauth (0.3.1)
simplecov (0.19.1) simplecov (0.20.0)
docile (~> 1.1) docile (~> 1.1)
simplecov-html (~> 0.11) simplecov-html (~> 0.11)
simplecov-cobertura (1.4.1) simplecov_json_formatter (~> 0.1)
simplecov-cobertura (1.4.2)
simplecov (~> 0.8) simplecov (~> 0.8)
simplecov-html (0.12.3) simplecov-html (0.12.3)
simplecov-json (0.2.3) simplecov-json (0.2.3)
json json
simplecov simplecov
simplecov_json_formatter (0.1.2)
spring (2.1.1) spring (2.1.1)
sprockets (3.7.2) sprockets (3.7.2)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
@ -542,7 +544,7 @@ GEM
multipart-post (~> 2.0) multipart-post (~> 2.0)
naught (~> 1.0) naught (~> 1.0)
simple_oauth (~> 0.3.0) simple_oauth (~> 0.3.0)
tzinfo (1.2.8) tzinfo (1.2.9)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (4.2.0) uglifier (4.2.0)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
@ -603,7 +605,7 @@ DEPENDENCIES
haml_lint haml_lint
hcaptcha (~> 6.0)! hcaptcha (~> 6.0)!
httparty httparty
i18n-js (= 3.0.0.rc10) i18n-js (= 3.6)
jbuilder (~> 2.10) jbuilder (~> 2.10)
jquery-minicolors-rails jquery-minicolors-rails
jquery-rails jquery-rails

View File

@ -11,6 +11,9 @@ import 'jquery.growl'
import NProgress from 'nprogress' import NProgress from 'nprogress'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
# this file is generated by Rails
import I18n from './i18n'
import './answerbox' import './answerbox'
import './questionbox' import './questionbox'
import './inbox' import './inbox'

View File

@ -20,7 +20,7 @@ module Justask
config.active_job.queue_adapter = :sidekiq config.active_job.queue_adapter = :sidekiq
config.i18n.default_locale = "en" config.i18n.default_locale = "en"
config.i18n.fallbacks = true config.i18n.fallbacks = [I18n.default_locale]
config.i18n.enforce_available_locales = false config.i18n.enforce_available_locales = false
config.after_initialize do config.after_initialize do

View File

@ -66,7 +66,7 @@ Rails.application.configure do
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found). # the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true config.i18n.fallbacks = [I18n.default_locale]
# Send deprecation notices to registered listeners. # Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify config.active_support.deprecation = :notify

View File

@ -24,5 +24,7 @@
fallbacks: :default_locale fallbacks: :default_locale
translations: translations:
- file: 'app/assets/javascripts/i18n/translations.js' - file: 'app/javascript/packs/legacy/i18n.js'
only: ['*.frontend.*', '*.views.actions.*'] only: ['*.frontend.*', '*.views.actions.*']
prefix: "import I18n from 'i18n-js'\n"
suffix: "\nexport default I18n"

View File

@ -3,6 +3,7 @@
"bootstrap": "^4.5.3", "bootstrap": "^4.5.3",
"cheet.js": "^0.3.3", "cheet.js": "^0.3.3",
"core-js": "^3.8.1", "core-js": "^3.8.1",
"i18n-js": "^3.8.0",
"jquery": "^3.5.1", "jquery": "^3.5.1",
"jquery-minicolors": "^2.1.10", "jquery-minicolors": "^2.1.10",
"jquery-ujs": "^1.2.2", "jquery-ujs": "^1.2.2",

1092
public/javascripts/i18n.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3540,6 +3540,11 @@ https-browserify@^1.0.0:
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=
i18n-js@^3.8.0:
version "3.8.0"
resolved "https://registry.yarnpkg.com/i18n-js/-/i18n-js-3.8.0.tgz#b8fd6b12e1d88cb71f9806c29bca7c31c012e504"
integrity sha512-hDsGgPuvw/2P+lXSbOafAwspK8Ste8YrwuuUg17W3wEcO1JkQxBlPgsN1t2+852nTnz4YSYTjZc/1nAA2PC/nw==
iconv-lite@0.4.24: iconv-lite@0.4.24:
version "0.4.24" version "0.4.24"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"