lib/utopia/localization.rb
# A wrapper to provide easy access to locale related data in the request.
A wrapper to provide easy access to locale related data in the request.
A wrapper to provide easy access to locale related data in the request .
def preferred_locales(env)
			return to_enum(:preferred_locales, env) unless block_given?
			locales = Set.new
			host_preferred_locales(env) do |locale|
				yield env.merge(CURRENT_LOCALE_KEY => locale) if locales.add? locale
			end
			request_preferred_locale(env) do |locale, path|
				env = env.merge(Rack::PATH_INFO => path.to_s)
				yield env.merge(CURRENT_LOCALE_KEY => locale) if locales.add? locale
			end
			browser_preferred_locales(env).each do |locale|
				yield env.merge(CURRENT_LOCALE_KEY => locale) if locales.add? locale
			end
			@default_locales.each do |locale|
				yield env.merge(CURRENT_LOCALE_KEY => locale) if locales.add? locale
			end
		end
def preferred_locales ( env ) return to_enum ( :preferred_locales , env ) unless block_given? locales = Set . new host_preferred_locales ( env ) do | locale | yield env . merge ( CURRENT_LOCALE_KEY => locale ) if locales . add? locale end request_preferred_locale ( env ) do | locale , path | env = env . merge ( Rack :: PATH_INFO => path . to_s ) yield env . merge ( CURRENT_LOCALE_KEY => locale ) if locales . add? locale end browser_preferred_locales ( env ) . each do | locale | yield env . merge ( CURRENT_LOCALE_KEY => locale ) if locales . add? locale end @default_locales . each do | locale | yield env . merge ( CURRENT_LOCALE_KEY => locale ) if locales . add? locale end end
A wrapper to provide easy access to locale related data in the request.
A wrapper to provide easy access to locale related data in the request .
# Keep track of what locales have been tried: # We have extracted a locale from the path, so from this point on we should use the updated path:
env