Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/i18n.rb')
-rw-r--r--lib/gitlab/i18n.rb54
1 files changed, 46 insertions, 8 deletions
diff --git a/lib/gitlab/i18n.rb b/lib/gitlab/i18n.rb
index 31952f75006..8fe5868ca57 100644
--- a/lib/gitlab/i18n.rb
+++ b/lib/gitlab/i18n.rb
@@ -44,30 +44,30 @@ module Gitlab
TRANSLATION_LEVELS = {
'bg' => 0,
'cs_CZ' => 0,
- 'da_DK' => 35,
+ 'da_DK' => 34,
'de' => 16,
'en' => 100,
'eo' => 0,
- 'es' => 34,
+ 'es' => 33,
'fil_PH' => 0,
- 'fr' => 98,
+ 'fr' => 99,
'gl_ES' => 0,
'id_ID' => 0,
'it' => 1,
- 'ja' => 29,
+ 'ja' => 31,
'ko' => 20,
- 'nb_NO' => 24,
+ 'nb_NO' => 23,
'nl_NL' => 0,
'pl_PL' => 3,
'pt_BR' => 57,
- 'ro_RO' => 94,
+ 'ro_RO' => 91,
'ru' => 26,
'si_LK' => 11,
'tr_TR' => 10,
- 'uk' => 54,
+ 'uk' => 55,
'zh_CN' => 98,
'zh_HK' => 1,
- 'zh_TW' => 99
+ 'zh_TW' => 98
}.freeze
private_constant :TRANSLATION_LEVELS
@@ -116,5 +116,43 @@ module Gitlab
def with_default_locale(&block)
with_locale(::I18n.default_locale, &block)
end
+
+ def setup(domain:, default_locale:)
+ setup_repositories(domain)
+ setup_default_locale(default_locale)
+ end
+
+ private
+
+ def setup_repositories(domain)
+ translation_repositories = [
+ (po_repository(domain, 'jh/locale') if Gitlab.jh?),
+ po_repository(domain, 'locale')
+ ].compact
+
+ FastGettext.add_text_domain(
+ domain,
+ type: :chain,
+ chain: translation_repositories,
+ ignore_fuzzy: true
+ )
+
+ FastGettext.default_text_domain = domain
+ end
+
+ def po_repository(domain, path)
+ FastGettext::TranslationRepository.build(
+ domain,
+ path: Rails.root.join(path),
+ type: :po,
+ ignore_fuzzy: true
+ )
+ end
+
+ def setup_default_locale(locale)
+ FastGettext.default_locale = locale
+ FastGettext.default_available_locales = available_locales
+ ::I18n.available_locales = available_locales
+ end
end
end