about summary refs log tree commit diff
path: root/app/lib/language_detector.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2017-09-09 23:56:21 -0500
committerDavid Yip <yipdw@member.fsf.org>2017-09-09 23:56:21 -0500
commit67ad4533732f2e5cfc8c7f7ad3abaf7a5eb2647b (patch)
tree011ea44fc94bcff6f8ec4e23c3edf887359243d2 /app/lib/language_detector.rb
parent3dff74eecf5387b92b862893248710d2efb90eec (diff)
parent90712d42933efd9978e4bbae82f81a4650aa4d84 (diff)
Merge tag 'v1.6.0rc4' into sync/upstream-1.6.0rc4
Conflicts:
      app/javascript/mastodon/features/getting_started/index.js
      app/javascript/packs/public.js
      app/javascript/styles/components.scss
Diffstat (limited to 'app/lib/language_detector.rb')
-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