Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Make LocaleExtractor recognize our js-<locale>.yaml file format

Christophe Bliard4dc45e05cd0c
diff --git a/spec/support/i18n_lazy_loading.rb b/spec/support/i18n_lazy_loading.rb
index 4e2768d1621..ca0a62c6556 100644
--- a/spec/support/i18n_lazy_loading.rb
+++ b/spec/support/i18n_lazy_loading.rb
@@ -29,3 +29,15 @@
# Lazy loads translations based on the current locale.
# It avoids a 2 to 4 seconds penalty when all locales are loaded.
I18n.backend = I18n::Backend::LazyLoadable.new(lazy_load: true)
+
+# Need to make LocaleExtractor recognize our js-<locale>.yaml file format
+module LocaleExtractorPatch
+ def self.locale_from_path(path)
+ locale = super
+ locale.to_s.delete_prefix("js-").to_sym if locale
+ # name = File.basename(path, ".*")
+ # locale = name.split("_").first.delete_prefix("js-")
+ # locale&.to_sym
+ end
+end
+I18n::Backend::LocaleExtractor.prepend(LocaleExtractorPatch)