Skip to content
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Prefix your message with one of the following:
validator. Remove it from your config file.
- [Added] A single plugin class can now appear multiple times in the pipeline
with different configurations, each running as an independent instance.
- [Changed] Export translations in parallel. To enable parallel mode, your
output file definition must include the `:locale` placeholder.

## v4.2.3 - Mar 29, 2023

Expand Down
1 change: 1 addition & 0 deletions i18n-js.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.3.1"
spec.add_dependency "glob", ">= 0.4.0"
spec.add_dependency "i18n"

Expand Down
15 changes: 12 additions & 3 deletions lib/i18n-js.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require "optparse"
require "erb"
require "digest/md5"
require "concurrent-ruby"

require_relative "i18n-js/schema"
require_relative "i18n-js/version"
Expand Down Expand Up @@ -56,11 +57,19 @@ def self.export_group(group:, plugins:)
exported_files = []

if output_file_path.include?(":locale")
promises = []

filtered_translations.each_key do |locale|
locale_file_path = output_file_path.gsub(":locale", locale.to_s)
exported_files << write_file(locale_file_path,
locale => filtered_translations[locale])
promises <<
Concurrent::Promises.future(
output_file_path.gsub(":locale", locale.to_s),
locale => filtered_translations[locale]
) do |locale_file_path, translations|
write_file(locale_file_path, translations)
end
end

exported_files = Concurrent::Promises.zip(*promises).value!
else
exported_files << write_file(output_file_path, filtered_translations)
end
Expand Down
Loading
Loading