Module: AiCli::Helpers::I18n
- Defined in:
- lib/aicli/helpers/i18n.rb
Constant Summary collapse
- LANGUAGES =
{ 'en' => 'English', 'zh-Hans' => '简体中文', 'zh-Hant' => '繁體中文', 'es' => 'Español', 'jp' => '日本語', 'ko' => '한국어', 'fr' => 'Français', 'de' => 'Deutsch', 'ru' => 'Русский', 'uk' => 'Українська', 'vi' => 'Tiếng Việt', 'ar' => 'العربية', 'pt' => 'Português', 'id' => 'Indonesia', 'it' => 'Italiano', 'tr' => 'Türkçe' }.freeze
Class Attribute Summary collapse
-
.current_lang ⇒ Object
readonly
Returns the value of attribute current_lang.
Class Method Summary collapse
Class Attribute Details
.current_lang ⇒ Object (readonly)
Returns the value of attribute current_lang.
28 29 30 |
# File 'lib/aicli/helpers/i18n.rb', line 28 def current_lang @current_lang end |
Class Method Details
.current_language_name ⇒ Object
41 42 43 |
# File 'lib/aicli/helpers/i18n.rb', line 41 def current_language_name LANGUAGES[@current_lang] || LANGUAGES['en'] end |
.languages ⇒ Object
45 46 47 |
# File 'lib/aicli/helpers/i18n.rb', line 45 def languages LANGUAGES end |
.set_language(lang) ⇒ Object
30 31 32 33 |
# File 'lib/aicli/helpers/i18n.rb', line 30 def set_language(lang) @current_lang = lang.nil? || lang.empty? ? 'en' : lang load_translations end |
.t(key) ⇒ Object
35 36 37 38 39 |
# File 'lib/aicli/helpers/i18n.rb', line 35 def t(key) return key if @current_lang.nil? || @current_lang == 'en' @translations[key] || key end |