module GScraper::Languages

@api semipublic

@since 0.3.0

Constants

NAMES

The list of language names

Public Class Methods

find(locale) click to toggle source

Looks up the language for the given locale.

@param [String] locale

A locale.

@return [String]

The language used by the locale.
# File lib/gscraper/languages.rb, line 87
def Languages.find(locale)
  if locale =~ /^zh_CN/
    'zh-CN'
  elsif locale =~ /^zh_TW/
    'zh-TW'
  else
    if (match = locale.match(/^([^_@]+)([_@].+)?$/))
      match[1] if (match[1] && NAMES.include?(match[1]))
    end
  end
end
native() click to toggle source

Determines the native language.

@return [String]

The native language.
# File lib/gscraper/languages.rb, line 105
def Languages.native
  language = ENV['LANG'] || 'en'
  Languages.find(language)
end