Skip to content

Commit

Permalink
whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Fuchs committed Nov 14, 2009
1 parent 6895734 commit 2bdac57
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
14 changes: 7 additions & 7 deletions lib/globalize/i18n/missing_translations_log_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# but additionally logs missing translations to a given log.
#
# Useful for identifying missing translations during testing.
#
# E.g.
#
# E.g.
#
# require 'globalize/i18n/missing_translations_log_handler
# I18n.missing_translations_logger = RAILS_DEFAULT_LOGGER
Expand All @@ -16,26 +16,26 @@

module I18n
@@missing_translations_logger = nil

class << self
def missing_translations_logger
@@missing_translations_logger ||= begin
require 'logger' unless defined?(Logger)
Logger.new(STDOUT)
end
end

def missing_translations_logger=(logger)
@@missing_translations_logger = logger
end

def missing_translations_log_handler(exception, locale, key, options)
if MissingTranslationData === exception
missing_translations_logger.warn(exception.message)
return exception.message
return exception.message
else
raise exception
end
end
end
end
end
6 changes: 3 additions & 3 deletions lib/globalize/i18n/missing_translations_raise_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# but also raises on missing translations.
#
# Useful for identifying missing translations during testing.
#
# E.g.
#
# E.g.
#
# require 'globalize/i18n/missing_translations_raise_handler
# I18n.exception_handler = :missing_translations_raise_handler
Expand All @@ -13,7 +13,7 @@ def missing_translations_raise_handler(exception, locale, key, options)
raise exception
end
end

# self.exception_handler = :missing_translations_raise_handler
end

Expand Down
20 changes: 10 additions & 10 deletions lib/globalize/load_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
#
# I18n.load_locales 'en-US', 'de-DE'
# I18n.load_locale 'en-US'
#
#
# This will lookup all files named like:
#
# 'path/to/dir/all.yml'
# 'path/to/dir/en-US.yml'
# 'path/to/dir/en-US/*.yml'
#
# The filenames will be passed to I18n.load_translations which delegates to
# The filenames will be passed to I18n.load_translations which delegates to
# the backend. So the actual behaviour depends on the implementation of the
# backend. I18n::Backend::Simple will be able to read YAML and plain Ruby
# backend. I18n::Backend::Simple will be able to read YAML and plain Ruby
# files. See the documentation for I18n.load_translations for details.

module Globalize
Expand All @@ -31,27 +31,27 @@ def extensions
@extensions ||= ['rb', 'yml']
end
attr_writer :extensions

def locales
@locales ||= ['*']
end
attr_writer :locales

def <<(path)
push path
end

def push(*paths)
super(*paths.map{|path| filenames(path) }.flatten.uniq.sort)
end

protected

def filenames(path)
return [path] if File.file? path
patterns(path).map{|pattern| Dir[pattern] }
end

def patterns(path)
locales.map do |locale|
extensions.map do |extension|
Expand All @@ -60,4 +60,4 @@ def patterns(path)
end.flatten.uniq
end
end
end
end
12 changes: 6 additions & 6 deletions lib/globalize/translation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ class Translation < String
class Attribute < Translation
attr_accessor :requested_locale, :locale, :key
end

class Static < Translation
attr_accessor :requested_locale, :locale, :key, :options, :plural_key, :original

def initialize(string, meta = nil)
self.original = string
super
end
end

def initialize(string, meta = nil)
set_meta meta
super string
end

def fallback?
locale.to_sym != requested_locale.to_sym
end

def set_meta(meta)
meta.each {|name, value| send :"#{name}=", value } if meta
end
end
end
end
10 changes: 5 additions & 5 deletions lib/rails_edge_load_path_patch.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module I18n
@@load_path = nil
@@default_locale = :'en-US'

class << self
def load_path
@@load_path ||= []
end

def load_path=(load_path)
@@load_path = load_path
end
Expand All @@ -17,14 +17,14 @@ def load_path=(load_path)
def initialized?
@initialized ||= false
end

protected

def init_translations
load_translations(*I18n.load_path)
@initialized = true
end

def lookup(locale, key, scope = [])
return unless key
init_translations unless initialized?
Expand All @@ -34,7 +34,7 @@ def lookup(locale, key, scope = [])
end

rails_dir = File.expand_path "#{File.dirname(__FILE__)}/../../../rails/"
paths = %w(actionpack/lib/action_view/locale/en-US.yml
paths = %w(actionpack/lib/action_view/locale/en-US.yml
activerecord/lib/active_record/locale/en-US.yml
activesupport/lib/active_support/locale/en-US.yml)
paths.each{|path| I18n.load_path << "#{rails_dir}/#{path}" }

0 comments on commit 2bdac57

Please sign in to comment.