lib/world-flags.rb in world-flags-0.2.3 vs lib/world-flags.rb in world-flags-0.2.4
- old
+ new
@@ -40,12 +40,16 @@
def locale code
flag_locale_map[code.to_sym] || code
end
- attr_accessor :locale_flag_map
+ attr_writer :locale_flag_map, :active_locales
+ def active_locales
+ @active_locales ||= [:en]
+ end
+
# translate locales to flag code: ISO_3166-1_alpha-2
def locale_flag_map
@locale_map ||= {
:en => :us,
:da => :dk,
@@ -69,10 +73,15 @@
raise ArgumentError, "Must be a hash, was: #{languages}" unless languages.kind_of?(Hash)
@languages = languages
end
def languages
- @languages ||= {:en => Languages.en}
+ @languages ||= begin
+ active_locales.inject({}) do |res, locale|
+ res[locale] = Languages.send(locale) if Languages.respond_to?(locale)
+ res
+ end
+ end
end
# Country helper macros
def country locale = :en, code = :en