diff options
author | Matt Jankowski <mjankowski@thoughtbot.com> | 2017-04-18 16:20:12 -0400 |
---|---|---|
committer | Eugen <eugen@zeonfederated.com> | 2017-04-18 22:20:12 +0200 |
commit | 297c11dba2864b20992cd3f98282f5ce35d5d144 (patch) | |
tree | fd4c3e3ec0c981b417931708c7f88cd25e6282c9 /app/services | |
parent | 0a7588282a00513af9631d06eea76878a974c659 (diff) |
Language detection refactor (#2099)
* Extract detect_language to separate class * Use default locale, not just en * Add spec to confirm that whatlanguage cant identify empty string * Allow account locale to override default in language detector * PostStatusService supplies an account to detect language
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/post_status_service.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 00af28edd..6ce434a13 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -19,7 +19,7 @@ class PostStatusService < BaseService sensitive: options[:sensitive], spoiler_text: options[:spoiler_text] || '', visibility: options[:visibility], - language: detect_language(text), + language: detect_language_for(text, account), application: options[:application]) attach_media(status, media) @@ -52,8 +52,8 @@ class PostStatusService < BaseService media.update(status_id: status.id) end - def detect_language(text) - WhatLanguage.new(:all).language_iso(text) || 'en' + def detect_language_for(text, account) + LanguageDetector.new(text, account).to_iso_s end def process_mentions_service |