about summary refs log tree commit diff
path: root/app/helpers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-09-08 12:32:22 +0200
committerGitHub <noreply@github.com>2017-09-08 12:32:22 +0200
commit1caf11ddcc029d9e7735ab3b90607ab2d6973034 (patch)
treef4642058d59360ea44ddf937c22b3835077719a6 /app/helpers
parent95f018a3d4f02ff4ce77d7b1cfa9a79fce3ce99a (diff)
Fix language filter codes (#4841)
* Fix language filter codes

CLD3 returns BCP-47 language identifier, filter settings expect
identifiers in the ISO 639-1 format. Convert between formats,
and exclude duplicate languages from filter choices (zh-CN->zh)

* Fix zh name
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/settings_helper.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index af950aa63..369a45680 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -30,6 +30,7 @@ module SettingsHelper
     th: 'ภาษาไทย',
     tr: 'Türkçe',
     uk: 'Українська',
+    zh: '中文',
     'zh-CN': '简体中文',
     'zh-HK': '繁體中文(香港)',
     'zh-TW': '繁體中文(臺灣)',
@@ -39,6 +40,10 @@ module SettingsHelper
     HUMAN_LOCALES[locale]
   end
 
+  def filterable_languages
+    I18n.available_locales.map { |locale| locale.to_s.split('-').first.to_sym }.uniq
+  end
+
   def hash_to_object(hash)
     HashObject.new(hash)
   end