lib/world_flags/util/language.rb in world-flags-0.4.1 vs lib/world_flags/util/language.rb in world-flags-0.4.2
- old
+ new
@@ -15,10 +15,19 @@
locale_languages_map = languages_map[:en] if locale_languages_map.blank?
raise "No language-locale map defined for locale: #{locale} or :en in #{languages.inspect}" if locale_languages_map.blank?
# raise("No language map defined for language code: #{code} in #{locale_languages_map[code]}")
- locale_languages_map[code] ? locale_languages_map[code] : locale_languages_map[default_code_used]
+ code_language = locale_languages_map[code] ? locale_languages_map[code] : locale_languages_map[default_code_used]
+
+ case code_language
+ when Array
+ code_language.join(',')
+ when String
+ code_language
+ else
+ raise "The language in the language map must be either a String or Array, was #{code_language.inspect}"
+ end
rescue Exception => e
raise e if WorldFlags.raise_error?
"Undefined"
end
\ No newline at end of file