Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Detect Rails version and set export directory accordingly.

  • Loading branch information...
commit 1d49c4e9dfdf106da41003206002391a76043bde 1 parent 40e59ae
Nando Vieira authored
1  .rspec
View
@@ -0,0 +1 @@
+--color --format documentation
12 lib/i18n-js.rb
View
@@ -13,8 +13,16 @@ def config_file
Rails.root.join("config/i18n-js.yml")
end
+ def export_dir
+ if Rails.version >= "3.1"
+ "vendor/assets/javascripts"
+ else
+ "public/javascripts"
+ end
+ end
+
def javascript_file
- Rails.root.join("public/javascripts/i18n.js")
+ Rails.root.join(export_dir, "i18n.js")
end
# Export translations to JavaScript, considering settings
@@ -32,7 +40,7 @@ def export!
end
end
else
- save translations, "public/javascripts/translations.js"
+ save translations, "#{export_dir}/translations.js"
end
end
14 spec/i18n_spec.rb
View
@@ -59,7 +59,7 @@
it "exports messages to default path when configuration file doesn't exist" do
SimplesIdeias::I18n.export!
- File.should be_file(Rails.root.join("public/javascripts/translations.js"))
+ Rails.root.join(SimplesIdeias::I18n.export_dir, "translations.js").should be_file
end
it "exports messages using the default configuration file" do
@@ -154,6 +154,18 @@
File.read(SimplesIdeias::I18n.javascript_file).should == "UPDATED"
end
+ describe "#export_dir" do
+ it "detects Rails 3.1" do
+ Rails.version = "3.1"
+ SimplesIdeias::I18n.export_dir == "vendor/assets/javascripts"
+ end
+
+ it "detects older Rails" do
+ Rails.version = "3.0.9"
+ SimplesIdeias::I18n.export_dir.to_s.should == "public/javascripts"
+ end
+ end
+
private
# Set the configuration as the current one
def set_config(path)
4 spec/resources/locales.yml
View
@@ -20,7 +20,7 @@ en:
abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
- order: [ :year, :month, :day ]
+ # order: [ :year, :month, :day ]
time:
formats:
default: "%a, %d %b %Y %H:%M:%S %z"
@@ -47,7 +47,7 @@ fr:
abbr_day_names: [dim, lun, mar, mer, jeu, ven, sam]
month_names: [~, janvier, février, mars, avril, mai, juin, juillet, août, septembre, octobre, novembre, décembre]
abbr_month_names: [~, jan., fév., mar., avr., mai, juin, juil., août, sept., oct., nov., déc.]
- order: [ :day, :month, :year ]
+ # order: [ :day, :month, :year ]
time:
formats:
default: "%d %B %Y %H:%M"
Please sign in to comment.
Something went wrong with that request. Please try again.