mirror of
https://ghfast.top/https://github.com/discourse/discourse-translator.git
synced 2026-07-15 11:36:26 +08:00
Currently, the button above shows up even when there are no posts translated. With this commit, we will not show the button if there are zero posts in the topic that is translated. This commit also - only returns translations of supported languages (in SiteSetting.automatic_translation_target_languages) - optimises loading translations when the feature is enabled under certain circumstances
15 lines
406 B
Ruby
15 lines
406 B
Ruby
# frozen_string_literal: true
|
|
|
|
module DiscourseTranslator
|
|
class LocaleMatcher
|
|
def self.user_locale_in_target_languages?
|
|
# e.g. "en|es|pt_BR" vs :en_UK
|
|
SiteSetting.automatic_translation_target_languages.split("|").include?(I18n.locale.to_s)
|
|
end
|
|
|
|
def self.user_locale_is_default?
|
|
# e.g. :en_UK vs "en_UK"
|
|
I18n.locale.to_s == SiteSetting.default_locale
|
|
end
|
|
end
|
|
end
|