blob: b6f81923b5f98fdf884ff1fe26fa9e35909ba592 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# frozen_string_literal: true
class LanguageDetector
attr_reader :text, :account
def initialize(text, account = nil)
@text = text
@account = account
end
def to_iso_s
WhatLanguage.new(:all).language_iso(text) || default_locale.to_sym
end
private
def default_locale
account&.user&.locale || I18n.default_locale
end
end
|