lib/knj/gettext_threadded.rb in knjrbfw-0.0.7 vs lib/knj/gettext_threadded.rb in knjrbfw-0.0.8
- old
+ new
@@ -38,33 +38,34 @@
def trans(locale, str)
locale = locale.to_s
str = str.to_s
- if !@langs.has_key?(locale)
+ if !@langs.key?(locale)
raise "Locale was not found: '#{locale}' in '#{@langs.keys.join(", ")}'."
end
- return str if !@langs[locale].has_key?(str)
+ return str if !@langs[locale].key?(str)
return @langs[locale][str]
end
#This function can be used to make your string be recognized by gettext tools.
def gettext(str, locale)
return trans(locale, str)
end
+ #Returns a hash with the language ID string as key and the language human-readable-title as value.
def lang_opts
langs = {}
@langs.keys.sort.each do |lang|
title = nil
@dirs.each do |dir|
title_file_path = "#{dir}/#{lang}/title.txt"
if File.exists?(title_file_path)
title = File.read(title_file_path).to_s.strip
else
- title = lang.strip
+ title = lang.to_s.strip
end
break if title
end
\ No newline at end of file