mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: moment_js locale files for zh_CN and zh_TW were not found
moment_js uses a different format for locale names in plugins and files in core. Follow-up to 4799cf2811
This commit is contained in:
parent
4799cf2811
commit
b3ab0e5753
@ -164,9 +164,9 @@ module JsLocaleHelper
|
|||||||
def self.find_moment_locale(locale_chain)
|
def self.find_moment_locale(locale_chain)
|
||||||
path = "#{Rails.root}/vendor/assets/javascripts/moment-locale"
|
path = "#{Rails.root}/vendor/assets/javascripts/moment-locale"
|
||||||
|
|
||||||
find_locale(locale_chain, path, :moment_js, fallback_to_english: false) do
|
find_locale(locale_chain, path, :moment_js, fallback_to_english: false) do |locale|
|
||||||
# moment.js uses a different naming scheme for locale files
|
# moment.js uses a different naming scheme for locale files
|
||||||
locale_chain.map { |l| l.tr('_', '-').downcase }
|
locale.tr('_', '-').downcase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -180,16 +180,18 @@ module JsLocaleHelper
|
|||||||
plugin_locale = DiscoursePluginRegistry.locales[locale]
|
plugin_locale = DiscoursePluginRegistry.locales[locale]
|
||||||
return plugin_locale[type] if plugin_locale&.has_key?(type)
|
return plugin_locale[type] if plugin_locale&.has_key?(type)
|
||||||
|
|
||||||
|
locale = yield(locale) if block_given?
|
||||||
filename = File.join(path, "#{locale}.js")
|
filename = File.join(path, "#{locale}.js")
|
||||||
return [locale, filename] if File.exist?(filename)
|
return [locale, filename] if File.exist?(filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
locale_chain = yield if block_given?
|
locale_chain.map! { |locale| yield(locale) } if block_given?
|
||||||
|
|
||||||
# try again, but this time only with the language itself
|
# try again, but this time only with the language itself
|
||||||
locale_chain = locale_chain.map { |l| l.split(/[-_]/)[0] }
|
locale_chain = locale_chain.map { |l| l.split(/[-_]/)[0] }
|
||||||
.uniq.reject { |l| locale_chain.include?(l) }
|
.uniq.reject { |l| locale_chain.include?(l) }
|
||||||
unless locale_chain.empty?
|
|
||||||
|
if locale_chain.any?
|
||||||
locale_data = find_locale(locale_chain, path, type, fallback_to_english: false)
|
locale_data = find_locale(locale_chain, path, type, fallback_to_english: false)
|
||||||
return locale_data if locale_data
|
return locale_data if locale_data
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user