Used for managing human languages.
Return an array of Language objects whose description match the given text.
# File lib/webgen/languages.rb, line 76 76: def self.find_language(text) 77: languages.values.find_all {|lang| /.*#{Regexp.escape(text)}.*/ =~ lang.description}.uniq.sort 78: end
Return a Language object for the given language code or nil if no such object exists.
# File lib/webgen/languages.rb, line 71 71: def self.language_for_code(code) 72: languages[code] 73: end
Return all available languages as a Hash. The keys are the language codes and the values are the Language objects for them.
# File lib/webgen/languages.rb, line 82 82: def self.languages 83: unless defined?(@@languages) 84: @@languages = {} 85: started = nil 86: data = File.readlines(__FILE__).each do |l| 87: next if !started && (started = (l == '__END__')) 88: data = l.chomp.split('|').collect {|f| f.empty? ? nil : f} 89: lang = Language.new(data[0..2], data[3]) 90: @@languages[lang.code2chars] ||= lang unless lang.code2chars.nil? 91: @@languages[lang.code3chars] ||= lang unless lang.code3chars.nil? 92: @@languages[lang.code3chars_alternative] ||= lang unless lang.code3chars_alternative.nil? 93: end 94: @@languages.freeze 95: end 96: @@languages 97: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.