about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/language_detector.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/lib/language_detector.rb b/app/lib/language_detector.rb
index cc7509fdc..1d9932b52 100644
--- a/app/lib/language_detector.rb
+++ b/app/lib/language_detector.rb
@@ -20,7 +20,16 @@ class LanguageDetector
   private
 
   def detected_language_code
-    result.language.to_sym if detected_language_reliable?
+    iso6391(result.language).to_sym if detected_language_reliable?
+  end
+
+  def iso6391(bcp47)
+    iso639 = bcp47.split('-').first
+
+    # CLD3 returns grandfathered language code for Hebrew
+    return 'he' if iso639 == 'iw'
+
+    ISO_639.find(iso639).alpha2
   end
 
   def result