Skip to content

Commit 9e787f4

Browse files
authored
Merge pull request #43 from AlchemyCMS/move-js-assets
Fix loading of JS locales
2 parents 144e881 + 563e660 commit 9e787f4

10 files changed

Lines changed: 13 additions & 18 deletions

File tree

β€ŽREADME.mdβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# AlchemyCMS Translations
22

3-
Translations files for AlchemyCMS 4.4 and above.
3+
Translations files for AlchemyCMS 6.0 and above.
44

55
## Installation
66

77
Add this Gem to your `Gemfile` and run the install generator
88

99
```
10+
bundle add alchemy_i18n
1011
bin/rails g alchemy_i18n:install
1112
```
1213

β€Žalchemy_i18n.gemspecβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
1616

1717
s.files = Dir["{app,locales,lib,vendor}/**/*", "CHANGELOG.md", "LICENSE", "README.md"]
1818

19-
s.add_dependency "alchemy_cms", [">= 4.4.0.a", "< 6.1"]
19+
s.add_dependency "alchemy_cms", [">= 6.0.0", "< 7"]
2020
s.add_dependency "rails-i18n"
2121

2222
s.add_development_dependency "github_changelog_generator"

β€Žlib/generators/alchemy_i18n/install/install_generator.rbβ€Ž

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,15 @@ def self.description
2020

2121
source_root AlchemyI18n::Engine.root
2222

23-
def copy_locales
24-
locales.each do |locale|
25-
js_filename = "#{locale}.js"
26-
copy_file File.join('app', 'assets', 'javascripts', 'alchemy_i18n', js_filename), Rails.root.join('vendor', 'assets', 'javascripts', 'alchemy_i18n', js_filename)
27-
copy_file File.join('vendor', 'assets', 'javascripts', 'flatpickr', js_filename), Rails.root.join('vendor', 'assets', 'javascripts', 'flatpickr', js_filename)
28-
end
29-
end
30-
3123
def append_assets
3224
locales.each do |locale|
3325
append_file 'vendor/assets/javascripts/alchemy/admin/all.js', <<~ASSETS
3426
//= require alchemy_i18n/#{locale}
3527
//= require select2_locale_#{locale}
36-
//= require flatpickr/#{locale}
3728
ASSETS
3829
end
3930
end
4031

41-
def copy_tinymce_locales
42-
locales.each do |locale|
43-
copy_file File.join("locales", "tinymce", "#{locale}.js"),
44-
Rails.root.join('vendor', 'assets', 'javascripts', 'tinymce', 'langs', "#{locale}.js")
45-
end
46-
end
47-
4832
def append_manifest
4933
locales.each do |locale|
5034
append_file 'app/assets/config/manifest.js', <<~MANIFEST
@@ -53,6 +37,16 @@ def append_manifest
5337
end
5438
end
5539

40+
def append_pack
41+
webpack_config = YAML.load_file(Rails.root.join("config", "webpacker.yml"))[Rails.env]
42+
pack = Rails.root.join(webpack_config["source_path"], webpack_config["source_entry_path"], "alchemy/admin.js")
43+
locales.each do |locale|
44+
append_file pack, <<~PACK
45+
import "flatpickr/dist/l10n/#{locale}.js"
46+
PACK
47+
end
48+
end
49+
5650
def add_rails_i18n
5751
environment do
5852
"config.i18n.available_locales = #{locales.map(&:to_sym).inspect}"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
Β (0)