Class: Koziolekweb::LanguageSupport::LanguageManager

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/koziolekweb/tags.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path, lang_data_path) ⇒ LanguageManager

Returns a new instance of LanguageManager.



192
193
194
195
196
197
# File 'lib/jekyll/koziolekweb/tags.rb', line 192

def initialize(config_path, lang_data_path)
  @dictionary_cache = {}
  @config_path = config_path
  @lang_data_path = lang_data_path
  @default_language = load_default_language
end

Instance Attribute Details

#default_languageObject (readonly)

Returns the value of attribute default_language.



191
192
193
# File 'lib/jekyll/koziolekweb/tags.rb', line 191

def default_language
  @default_language
end

Instance Method Details

#translate(key, lang = nil, default_value = nil) ⇒ Object

Pobiera tłumaczenie dla danego klucza



200
201
202
203
# File 'lib/jekyll/koziolekweb/tags.rb', line 200

def translate(key, lang = nil, default_value = nil)
  lang ||= default_language
  load_dictionary(lang)[key] || default_value
end