ember-i18n-rails 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ember-i18n-rails (0.2.0)
4
+ ember-i18n-rails (0.3.0)
5
5
  i18n
6
6
 
7
7
  GEM
@@ -1,22 +1,2 @@
1
1
  # Split context in several files.
2
- # By default only one file with all translations is exported and
3
- # no configuration is required. Your settings for asset pipeline
4
- # are automatically recognized.
5
- #
6
- # If you want to split translations into several files or specify
7
- # locale contexts that will be exported, just use this file to do
8
- # so.
9
- #
10
- # If you're going to use the Rails 3.1 asset pipeline, change
11
- # the following configuration to something like this:
12
- #
13
- # translations:
14
- # - file: "app/assets/javascripts/i18n/translations.js"
15
- #
16
- # If you're running an old version, you can use something
17
- # like this:
18
- #
19
- # translations:
20
- # - file: "public/javascripts/translations.js"
21
- # only: "*"
22
- #
2
+ split: true
@@ -39,7 +39,13 @@ module Ember
39
39
  # Export translations to JavaScript, considering settings
40
40
  # from configuration file
41
41
  def export!
42
- save(flat_hash(translations), File.join(export_dir, "translations.js"))
42
+ if config[:split]
43
+ translations.keys.each do |locale|
44
+ save(flat_hash(translations[locale]), File.join(export_dir, "translations_#{locale}.js"))
45
+ end
46
+ else
47
+ save(flat_hash(translations), File.join(export_dir, "translations.js"))
48
+ end
43
49
  end
44
50
 
45
51
  def flat_hash(data, prefix = '', result = {})
@@ -56,11 +62,27 @@ module Ember
56
62
  result.stringify_keys
57
63
  end
58
64
 
65
+ # Load configuration file for partial exporting and
66
+ # custom output directory
67
+ def config
68
+ if config?
69
+ (YAML.load_file(config_file) || {}).with_indifferent_access
70
+ else
71
+ {}
72
+ end
73
+ end
74
+
75
+ # Check if configuration file exist
76
+ def config?
77
+ File.file? config_file
78
+ end
79
+
59
80
  # Copy configuration and JavaScript library files to
60
81
  # <tt>config/ember-i18n.yml</tt> and <tt>public/javascripts/i18n.js</tt>.
61
82
  def setup!
62
83
  FileUtils.mkdir_p(export_dir)
63
84
  FileUtils.cp(File.dirname(__FILE__) + "/../vendor/assets/javascripts/ember-i18n.js", javascript_file)
85
+ FileUtils.cp(File.dirname(__FILE__) + "/../config/ember-i18n.yml", config_file) unless config?
64
86
  end
65
87
 
66
88
  # Retrieve an updated JavaScript library from Github.
@@ -2,7 +2,7 @@ module Ember
2
2
  module I18n
3
3
  module Version
4
4
  MAJOR = 0
5
- MINOR = 2
5
+ MINOR = 3
6
6
  PATCH = 0
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-i18n-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  segments:
149
149
  - 0
150
- hash: 1597518861932521648
150
+ hash: -4330185862975477695
151
151
  required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  none: false
153
153
  requirements:
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  segments:
158
158
  - 0
159
- hash: 1597518861932521648
159
+ hash: -4330185862975477695
160
160
  requirements: []
161
161
  rubyforge_project:
162
162
  rubygems_version: 1.8.23