Skip to content

Commit

Permalink
Merge pull request #51 from AlchemyCMS/pin-locales
Browse files Browse the repository at this point in the history
Import flatpickr translations into Alchemy admin
  • Loading branch information
tvdeyen authored Oct 6, 2023
2 parents ceaebf7 + 8e40388 commit 2eb0009
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# AlchemyCMS Translations

Translations files for AlchemyCMS 6.0 and above.
Translations files for AlchemyCMS 7.0 and above.

## Alchemy version

For a Alchemy 5.3 compatible version use v2.3.1 or the `2.3-stable` branch.
- For a Alchemy 6.1 compatible version use v3.2.0 or the `3.2-stable` branch.
- For a Alchemy 5.3 compatible version use v2.3.1 or the `2.3-stable` branch.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion alchemy_i18n.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |s|

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

s.add_dependency "alchemy_cms", [">= 6.0.0", "< 8"]
s.add_dependency "alchemy_cms", [">= 7.0.4", "< 8"]
s.add_dependency "rails-i18n"

s.add_development_dependency "github_changelog_generator"
Expand Down
4 changes: 4 additions & 0 deletions lib/alchemy_i18n/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ class Engine < ::Rails::Engine
pattern = locales.empty? ? "*" : "{#{locales.join ","}}"
files = Dir[root.join("locales", "alchemy.#{pattern}.yml")]
I18n.load_path.concat(files)
locales.each do |locale|
Alchemy.importmap.pin "flatpickr/#{locale}.js", to: "https://ga.jspm.io/npm:flatpickr@4.6.13/dist/l10n/#{locale}.js"
Alchemy.admin_js_imports << "flatpickr/#{locale}.js"
end
end
end
end
18 changes: 0 additions & 18 deletions lib/generators/alchemy_i18n/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,6 @@ def append_manifest
end
end

def append_pack
app_root = Rails.root
config_file = app_root.join("config", "webpacker.yml")
if config_file.exist?
webpack_config = YAML.load_file(config_file)[Rails.env]
pack = app_root.join(
webpack_config["source_path"],
webpack_config["source_entry_path"],
"alchemy/admin.js"
)
else
pack = app_root.join("app/javascript/alchemy_admin.js")
end
additional_locales.each { |locale| append_file pack, <<~PACK }
import "flatpickr/dist/l10n/#{locale}.js"
PACK
end

def add_rails_i18n
environment do
"config.i18n.available_locales = #{locales.inspect}"
Expand Down

0 comments on commit 2eb0009

Please sign in to comment.