summaryrefslogtreecommitdiff
path: root/vendor/plugins/globalize2/lib/globalize/load_path.rb
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2010-01-14 22:21:43 +0100
committerhukl <contact@smyck.org>2010-01-14 22:21:43 +0100
commit57d1382013c85a7b11ac8ce5e683f6006b12b328 (patch)
tree19646c4fa5952fa1cf0a2c874952affa346373f1 /vendor/plugins/globalize2/lib/globalize/load_path.rb
parent1b86bf5f2e35d1820bfa32d979bcc2d9ff9a9a8e (diff)
Updated globalize2 to latest version. Modified existing code accoringly
Diffstat (limited to 'vendor/plugins/globalize2/lib/globalize/load_path.rb')
-rw-r--r--vendor/plugins/globalize2/lib/globalize/load_path.rb63
1 files changed, 0 insertions, 63 deletions
diff --git a/vendor/plugins/globalize2/lib/globalize/load_path.rb b/vendor/plugins/globalize2/lib/globalize/load_path.rb
deleted file mode 100644
index a49825b3..00000000
--- a/vendor/plugins/globalize2/lib/globalize/load_path.rb
+++ /dev/null
@@ -1,63 +0,0 @@
1# Locale load_path and Locale loading support.
2#
3# To use this include the Globalize::LoadPath::I18n module to I18n like this:
4#
5# I18n.send :include, Globalize::LoadPath::I18n
6#
7# Clients can add load_paths using:
8#
9# I18n.load_path.add load_path, 'rb', 'yml' # pass any number of extensions like this
10# I18n.load_path << 'path/to/dir' # usage without an extension, defaults to 'yml'
11#
12# And load locale data using either of:
13#
14# I18n.load_locales 'en-US', 'de-DE'
15# I18n.load_locale 'en-US'
16#
17# This will lookup all files named like:
18#
19# 'path/to/dir/all.yml'
20# 'path/to/dir/en-US.yml'
21# 'path/to/dir/en-US/*.yml'
22#
23# The filenames will be passed to I18n.load_translations which delegates to
24# the backend. So the actual behaviour depends on the implementation of the
25# backend. I18n::Backend::Simple will be able to read YAML and plain Ruby
26# files. See the documentation for I18n.load_translations for details.
27
28module Globalize
29 class LoadPath < Array
30 def extensions
31 @extensions ||= ['rb', 'yml']
32 end
33 attr_writer :extensions
34
35 def locales
36 @locales ||= ['*']
37 end
38 attr_writer :locales
39
40 def <<(path)
41 push path
42 end
43
44 def push(*paths)
45 super(*paths.map{|path| filenames(path) }.flatten.uniq.sort)
46 end
47
48 protected
49
50 def filenames(path)
51 return [path] if File.file? path
52 patterns(path).map{|pattern| Dir[pattern] }
53 end
54
55 def patterns(path)
56 locales.map do |locale|
57 extensions.map do |extension|
58 %W(#{path}/all.#{extension} #{path}/#{locale}.#{extension} #{path}/#{locale}/**/*.#{extension})
59 end
60 end.flatten.uniq
61 end
62 end
63end \ No newline at end of file