Skip to content

Commit

Permalink
Rename I18n#translations_dir to translation_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Sep 7, 2009
1 parent cf99c72 commit ad2b6aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions r18n-core/lib/r18n-core/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,25 @@ def self.parse_http(str)
attr_reader :locales

# Dirs with translations files
attr_reader :translations_dirs
attr_reader :translation_dirs

# First locale with locale file
attr_reader :locale

# Create i18n for +locales+ with translations from +translations_dirs+ and
# Create i18n for +locales+ with translations from +translation_dirs+ and
# locales data. Translations will be also loaded for default locale,
# +sublocales+ from first in +locales+ and general languages for dialects
# (it will load +fr+ for +fr_CA+ too).
#
# +Locales+ must be a locale code (RFC 3066) or array, ordered by priority.
# +Translations_dirs+ must be a string with path or array.
def initialize(locales, translations_dirs = nil)
# +Translation_dirs+ must be a string with path or array.
def initialize(locales, translation_dirs = nil)
locales = [locales] if locales.is_a? String

@locales = locales.map { |i| Locale.load(i) }

locales << @@default
if @locales.first.kind_of? Locale
if @locales.first.supported?
locales += @locales.first['sublocales']
end
locales.each_with_index do |locale, i|
Expand All @@ -126,19 +126,20 @@ def initialize(locales, translations_dirs = nil)
end
end

if translations_dirs.nil?
if translation_dirs.nil?
@translation_dirs = []
@translation = Translation.load(locales,
Translation.extension_translations)
else
@translations_dirs = translations_dirs
@translation = Translation.load(locales, @translations_dirs)
@translation_dirs = translation_dirs
@translation = Translation.load(locales, @translation_dirs)
end
end

# Return Hash with titles (or code for unsupported locales) for available
# translations.
def translations
Translation.available(@translations_dirs).inject({}) do |all, code|
Translation.available(@translation_dirs).inject({}) do |all, code|
all[code] = Locale.load(code)['title']
all
end
Expand Down
2 changes: 1 addition & 1 deletion r18n-core/spec/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

it "should return translations dir" do
i18n = R18n::I18n.new('en', DIR)
i18n.translations_dirs.expand_path.to_s.should == DIR.expand_path.to_s
i18n.translation_dirs.expand_path.to_s.should == DIR.expand_path.to_s
end

it "should load translations" do
Expand Down

0 comments on commit ad2b6aa

Please sign in to comment.