Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import flatpickr translations into Alchemy admin #51

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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