Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

whitespace

  • Loading branch information...
commit 2bdac5776a2f465a218e9764c962d2d591a8f991 1 parent 6895734
@svenfuchs svenfuchs authored
View
14 lib/globalize/i18n/missing_translations_log_handler.rb
@@ -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
@@ -16,7 +16,7 @@
module I18n
@@missing_translations_logger = nil
-
+
class << self
def missing_translations_logger
@@missing_translations_logger ||= begin
@@ -24,18 +24,18 @@ def missing_translations_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
View
6 lib/globalize/i18n/missing_translations_raise_handler.rb
@@ -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
@@ -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
View
20 lib/globalize/load_path.rb
@@ -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
@@ -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|
@@ -60,4 +60,4 @@ def patterns(path)
end.flatten.uniq
end
end
-end
+end
View
12 lib/globalize/translation.rb
@@ -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
View
10 lib/rails_edge_load_path_patch.rb
@@ -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
@@ -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?
@@ -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}" }
Please sign in to comment.
Something went wrong with that request. Please try again.