Use more generic locale as fallback for rules (#34756)
This commit is contained in:
parent
97b9e8849d
commit
6ab96ba647
4 changed files with 15 additions and 4 deletions
|
@ -42,6 +42,6 @@ class Rule < ApplicationRecord
|
|||
|
||||
def translation_for(locale)
|
||||
@cached_translations ||= {}
|
||||
@cached_translations[locale] ||= translations.find_by(language: locale) || RuleTranslation.new(language: locale, text: text, hint: hint)
|
||||
@cached_translations[locale] ||= translations.where(language: [locale, locale.to_s.split('-').first]).order('length(language) desc').first || RuleTranslation.new(language: locale, text: text, hint: hint)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue