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

hacks the hacky hacksaw

Marcello Rocha9ffe495b984a
diff --git a/spec/support/i18n_lazy_loading.rb b/spec/support/i18n_lazy_loading.rb
index ca0a62c6556..0a06b436049 100644
--- a/spec/support/i18n_lazy_loading.rb
+++ b/spec/support/i18n_lazy_loading.rb
@@ -28,16 +28,19 @@
# 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
+
+require "i18n/backend/lazy_loadable"
+
+class I18n::Backend::LocaleExtractor
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
+ name = File.basename(path, ".*")
+ locale = name.split("_").first
+
+ return if locale.nil?
+
+ locale.tr("js-", "").to_sym
end
end
-I18n::Backend::LocaleExtractor.prepend(LocaleExtractorPatch)
+
+I18n.backend = I18n::Backend::LazyLoadable.new(lazy_load: true)