i18n_sync 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +34 -7
- data/Rakefile +9 -14
- data/VERSION +1 -1
- data/bin/i18s +16 -8
- data/i18n_sync.gemspec +33 -28
- data/lib/i18n_sync.rb +57 -47
- data/spec/fixtures/children.en.yml +14 -0
- data/spec/fixtures/children.pt.yml +8 -0
- data/spec/i18n_sync_spec.rb +66 -13
- data/spec/results/children.pt.yml +16 -0
- data/spec/results/extra.pt.yml +6 -0
- data/spec/results/named.pt.yml +5 -0
- data/spec/results/order.en.yml +6 -0
- metadata +14 -9
data/README.rdoc
CHANGED
@@ -1,21 +1,47 @@
|
|
1
|
-
|
1
|
+
i18n Sync!
|
2
|
+
==========
|
2
3
|
|
3
4
|
Syncs all locale yml/rb files based on a "master" one.
|
4
5
|
|
5
6
|
|
6
|
-
|
7
|
+
Install
|
8
|
+
-------
|
7
9
|
|
8
|
-
|
10
|
+
gem install i18n_sync
|
9
11
|
|
10
12
|
|
11
|
-
|
13
|
+
Use
|
14
|
+
---
|
12
15
|
|
13
|
-
|
16
|
+
|
17
|
+
i18s path/to/master/file.lang.yml
|
14
18
|
|
15
19
|
All other yml should be located on the same folder as the "master".
|
16
20
|
|
21
|
+
Example:
|
22
|
+
|
23
|
+
|
24
|
+
i18s config/locales/app.en.yml
|
25
|
+
|
26
|
+
This command syncs all config/locale/app.*.yml files
|
27
|
+
using en as the master.
|
28
|
+
|
29
|
+
|
30
|
+
Other Options
|
31
|
+
-------------
|
32
|
+
|
33
|
+
i18s add some.very.nested.key Value path/to/file
|
34
|
+
|
35
|
+
Adds the new key on the file and every other translation.
|
36
|
+
|
37
|
+
|
38
|
+
i18s path/to/directory
|
39
|
+
|
40
|
+
Syncronizes the entire directory.
|
41
|
+
|
17
42
|
|
18
|
-
|
43
|
+
Note on Patches/Pull Requests
|
44
|
+
-----------------------------
|
19
45
|
|
20
46
|
* Fork the project.
|
21
47
|
* Make your feature addition or bug fix.
|
@@ -25,6 +51,7 @@ All other yml should be located on the same folder as the "master".
|
|
25
51
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
26
52
|
* Send me a pull request. Bonus points for topic branches.
|
27
53
|
|
28
|
-
|
54
|
+
Copyright
|
55
|
+
---------
|
29
56
|
|
30
57
|
Copyright (c) 2010 Marcos Piccinini. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
3
5
|
|
4
6
|
begin
|
5
7
|
require 'jeweler'
|
@@ -11,7 +13,7 @@ begin
|
|
11
13
|
gem.homepage = "http://github.com/nofxx/i18n_sync"
|
12
14
|
gem.authors = ["Marcos Piccinini"]
|
13
15
|
gem.add_dependency "ya2yaml"
|
14
|
-
gem.add_development_dependency "rspec", ">=
|
16
|
+
gem.add_development_dependency "rspec", ">= 2.5.0"
|
15
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
18
|
end
|
17
19
|
Jeweler::GemcutterTasks.new
|
@@ -19,21 +21,14 @@ rescue LoadError
|
|
19
21
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
22
|
end
|
21
23
|
|
22
|
-
# require 'spec/rake/spectask'
|
23
|
-
# Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
-
# spec.libs << 'lib' << 'spec'
|
25
|
-
# spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
-
# end
|
27
|
-
|
28
|
-
# Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
-
# spec.libs << 'lib' << 'spec'
|
30
|
-
# spec.pattern = 'spec/**/*_spec.rb'
|
31
|
-
# spec.rcov = true
|
32
|
-
# end
|
33
24
|
|
34
|
-
|
25
|
+
desc "Runs spec suite"
|
26
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
27
|
+
spec.pattern = 'spec/*_spec.rb'
|
28
|
+
spec.rspec_opts = ['--backtrace --colour']
|
29
|
+
end
|
35
30
|
|
36
|
-
|
31
|
+
task :default => :spec
|
37
32
|
|
38
33
|
require 'rake/rdoctask'
|
39
34
|
Rake::RDocTask.new do |rdoc|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/bin/i18s
CHANGED
@@ -14,7 +14,7 @@ require 'optparse'
|
|
14
14
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
15
15
|
require 'i18n_sync'
|
16
16
|
|
17
|
-
Options = {}
|
17
|
+
Options = {:lang => :en}
|
18
18
|
|
19
19
|
parser = OptionParser.new do |opts|
|
20
20
|
opts.banner = <<BANNER
|
@@ -24,8 +24,9 @@ Usage: #{File.basename($0)} <path/to/master.yml> [args]
|
|
24
24
|
|
25
25
|
Options are:
|
26
26
|
|
27
|
-
-
|
28
|
-
-
|
27
|
+
-l --lang LANG - Select a default language
|
28
|
+
-o --order - Order by name
|
29
|
+
-t --trace - Be more verbose
|
29
30
|
|
30
31
|
Common usage:
|
31
32
|
|
@@ -34,15 +35,22 @@ Common usage:
|
|
34
35
|
|
35
36
|
|
36
37
|
BANNER
|
38
|
+
opts.on("-l LANGUAGE", "--lang", "Default Language" ) { |l| Options[:lang] = l }
|
37
39
|
opts.on("-O", "--no-order", "Table order" ) { Options[:order] = false }
|
38
|
-
opts.on("-
|
40
|
+
opts.on("-v", "--verbose") { Options[:debug] = true }
|
39
41
|
opts.parse!(ARGV)
|
40
42
|
end
|
41
43
|
|
42
44
|
if ARGV.empty?
|
43
|
-
|
44
|
-
|
45
|
+
# ipaths = %w{ config/locales lib/locales }.select { |ipath| File.exists?(ipath) }
|
46
|
+
# unless ipaths.empty?
|
47
|
+
# ipaths.each { |i| I18S.work_on(i) }
|
48
|
+
# else
|
49
|
+
puts parser.banner
|
50
|
+
exit
|
51
|
+
# end
|
52
|
+
elsif ARGV[0] == "add"
|
53
|
+
I18S.add_key *ARGV[1..-1]
|
45
54
|
else
|
46
|
-
|
47
|
-
syncr.work
|
55
|
+
I18S.work_on ARGV, Options # ARGF
|
48
56
|
end
|
data/i18n_sync.gemspec
CHANGED
@@ -1,63 +1,68 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{i18n_sync}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marcos Piccinini"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-06-06}
|
13
13
|
s.default_executable = %q{i18s}
|
14
14
|
s.description = %q{Gem to sync all locale yml/rb files based on a "master" one.}
|
15
15
|
s.email = %q{x@nofxx.com}
|
16
16
|
s.executables = ["i18s"]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
19
|
-
|
19
|
+
"README.rdoc"
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bin/i18s",
|
28
|
+
"i18n_sync.gemspec",
|
29
|
+
"lib/i18n_sync.rb",
|
30
|
+
"spec/fixtures/children.en.yml",
|
31
|
+
"spec/fixtures/children.pt.yml",
|
32
|
+
"spec/fixtures/en.yml",
|
33
|
+
"spec/fixtures/extra.en.yml",
|
34
|
+
"spec/fixtures/extra.pt.yml",
|
35
|
+
"spec/fixtures/named.en.yml",
|
36
|
+
"spec/fixtures/named.pt.yml",
|
37
|
+
"spec/fixtures/order.en.yml",
|
38
|
+
"spec/fixtures/order.pt.yml",
|
39
|
+
"spec/fixtures/pt.yml",
|
40
|
+
"spec/i18n_sync_spec.rb",
|
41
|
+
"spec/results/children.pt.yml",
|
42
|
+
"spec/results/extra.pt.yml",
|
43
|
+
"spec/results/named.pt.yml",
|
44
|
+
"spec/results/order.en.yml",
|
45
|
+
"spec/spec_helper.rb"
|
39
46
|
]
|
40
47
|
s.homepage = %q{http://github.com/nofxx/i18n_sync}
|
41
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
42
48
|
s.require_paths = ["lib"]
|
43
49
|
s.rubygems_version = %q{1.3.7}
|
44
50
|
s.summary = %q{Syncs all locale yml/rb files based on a "master" one.}
|
45
|
-
s.test_files = [
|
46
|
-
"spec/spec_helper.rb",
|
47
|
-
"spec/i18n_sync_spec.rb"
|
48
|
-
]
|
49
51
|
|
50
52
|
if s.respond_to? :specification_version then
|
51
53
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
52
54
|
s.specification_version = 3
|
53
55
|
|
54
56
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
-
s.
|
57
|
+
s.add_runtime_dependency(%q<ya2yaml>, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<rspec>, [">= 2.5.0"])
|
56
59
|
else
|
57
|
-
s.add_dependency(%q<
|
60
|
+
s.add_dependency(%q<ya2yaml>, [">= 0"])
|
61
|
+
s.add_dependency(%q<rspec>, [">= 2.5.0"])
|
58
62
|
end
|
59
63
|
else
|
60
|
-
s.add_dependency(%q<
|
64
|
+
s.add_dependency(%q<ya2yaml>, [">= 0"])
|
65
|
+
s.add_dependency(%q<rspec>, [">= 2.5.0"])
|
61
66
|
end
|
62
67
|
end
|
63
68
|
|
data/lib/i18n_sync.rb
CHANGED
@@ -1,58 +1,96 @@
|
|
1
1
|
#
|
2
|
-
#
|
2
|
+
# Inspired by translation rake task on spree (http://spreecommerce.com/)
|
3
3
|
#
|
4
|
+
# Changed to use YAML instead of text regex, but yaml has issues so we need to:
|
4
5
|
require 'ya2yaml'
|
6
|
+
# To work with utf8 encoded .yml files.
|
7
|
+
|
8
|
+
|
9
|
+
class Hash
|
10
|
+
def deep_merge!(other_hash)
|
11
|
+
other_hash.each do |k,v|
|
12
|
+
next unless tv = self[k]
|
13
|
+
self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.dup.deep_merge!(v) : v
|
14
|
+
end
|
15
|
+
self
|
16
|
+
end
|
17
|
+
end
|
5
18
|
|
6
19
|
class I18S
|
7
20
|
|
8
|
-
|
21
|
+
# Just here cuz I'm lazy....TBF really ugly ! ! ! !
|
22
|
+
def self.work_on(argv, opts = {}, argf = [])
|
23
|
+
if File.directory? path = argv[0]
|
24
|
+
Dir["#{path}/**"].map do |file|
|
25
|
+
next unless file =~ /(^|\.)#{opts[:lang]}\./
|
26
|
+
new([file], opts, argf)
|
27
|
+
end.reject(&:nil?)
|
28
|
+
else
|
29
|
+
[new(argv, opts, argf)]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.recursive_hash
|
34
|
+
Hash.new { |h,k| h[k] = recursive_hash }
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.add_key(key, val, file)
|
38
|
+
hsh = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }#recursive_hash
|
39
|
+
keys = key.split(".")
|
40
|
+
keys.reduce(hsh) do |a, k|
|
41
|
+
k == keys[-1] ? a[k] = val : a = a[k]
|
42
|
+
end
|
43
|
+
new(file, {}, hsh)
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize(argv, opts = {}, keys = {}, argf=[])
|
9
47
|
# argf.each { |file| p file }
|
10
48
|
@fullpath, *@new_ones = argv
|
11
49
|
@file, *path = @fullpath.split("/").reverse # hm.. hack,,, in 1.9
|
12
50
|
@path = path.reverse.join("/") || "." # can splat the first
|
13
51
|
_, @lang, @namespace = @file.split(".").reverse
|
14
|
-
@debug = opts[:
|
52
|
+
@debug = opts[:debug]
|
15
53
|
@order = opts[:order]
|
16
54
|
@comments, @words = read_file(@fullpath, @lang)
|
55
|
+
@words.merge! keys unless keys.empty?
|
56
|
+
work
|
17
57
|
end
|
18
58
|
|
19
59
|
def work
|
20
|
-
|
60
|
+
out "Start work on #{@file} (#{@lang})"
|
21
61
|
@new_ones.empty? ? sync : create_new_files
|
22
62
|
end
|
23
63
|
|
24
64
|
def create_new_files
|
25
|
-
@new_ones.each do |
|
26
|
-
puts "Creating new file #{
|
27
|
-
create
|
65
|
+
@new_ones.each do |name|
|
66
|
+
puts "Creating new file #{name}"
|
67
|
+
create name
|
28
68
|
end
|
29
69
|
end
|
30
70
|
|
31
71
|
def sync
|
32
72
|
Dir["#{@path}/*.{yml,rb}"].each do |filename|
|
33
|
-
|
34
|
-
next if filename =~ /#{@file}/
|
35
|
-
lang, namespace = File.basename(filename, '.yml').split(".").reverse #filename.split("/").last.split(".").reverse
|
73
|
+
lang, namespace = File.basename(filename, '.yml').split(".").reverse
|
36
74
|
if namespace
|
37
75
|
next unless @namespace && @namespace == namespace
|
38
76
|
else
|
39
77
|
next if @namespace
|
40
78
|
end
|
41
79
|
|
42
|
-
|
43
|
-
(_comments,
|
80
|
+
out "Writing #{filename}"
|
81
|
+
(_comments, old) = read_file(filename, lang)
|
44
82
|
# Initializing hash variable as empty if it does not exist
|
45
|
-
|
46
|
-
# Remove if not defined in master
|
47
|
-
other.delete_if { |k,v| !@words[k] }
|
83
|
+
other = @words.dup.deep_merge! old
|
48
84
|
write_file(filename, lang, @comments, other)
|
49
85
|
end
|
50
86
|
end
|
51
87
|
|
52
|
-
def create
|
53
|
-
|
88
|
+
def create newlang
|
89
|
+
# New name "app.en.yml" -> "app.pt.yml", "en.yml" -> "pt.yml"
|
90
|
+
newname = @file.gsub(/(^|\.)#{@lang}\./, "\\1#{newlang}.")
|
91
|
+
fullpath = "#{@path}/#{newname}"
|
54
92
|
return puts("File exists.") if File.exists?(fullpath)
|
55
|
-
write_file(fullpath,
|
93
|
+
write_file(fullpath, newlang, @comments, @words)
|
56
94
|
end
|
57
95
|
|
58
96
|
#Retrieve comments, translation data in hash form
|
@@ -61,40 +99,12 @@ class I18S
|
|
61
99
|
[comments, YAML.load(File.open(filename, "r:utf-8"))[basename]]
|
62
100
|
end
|
63
101
|
|
64
|
-
#Creates hash of translation data
|
65
|
-
#def create_hash(data, filename)
|
66
|
-
# return {} unless data
|
67
|
-
# words = Hash.new
|
68
|
-
# return words if !data
|
69
|
-
# parent = Array.new
|
70
|
-
# previous_key = 'base'
|
71
|
-
# data.split("\n").each do |w|
|
72
|
-
# next if w.strip.empty?
|
73
|
-
# w.sub!(":", "") if w =~ /^(\s*)\:/
|
74
|
-
# (key, *value) = w.split(':')
|
75
|
-
# value = value.join# ||= ''
|
76
|
-
# shift = (key =~ /\w/)/2 - parent.size #Determine level of current key in comparison to parent array
|
77
|
-
# key = key.sub(/^\s+/,'')
|
78
|
-
# parent << previous_key if shift > 0 #If key is child of previous key, add previous key as parent
|
79
|
-
# (shift*-1).times { parent.pop } if shift < 0 #If key is not related to previous key, remove parent keys
|
80
|
-
# previous_key = key #Track key in case next key is child of this key
|
81
|
-
# words[parent.join(':')+':'+key] = value
|
82
|
-
# end
|
83
|
-
# words
|
84
|
-
#end
|
85
|
-
|
86
102
|
#Writes to file from translation data hash structure
|
87
103
|
def write_file(filename, basename, comments, data)
|
88
104
|
File.delete filename if File.exists? filename
|
89
105
|
File.open(filename, "w:utf-8") do |y|
|
90
106
|
y.puts(comments) if comments
|
91
|
-
|
92
|
-
y.puts({ basename => data }.ya2yaml )# (:sick_compatible => true))
|
93
|
-
# words.sort.each do |k,v|
|
94
|
-
# keys = k.split(':')
|
95
|
-
# (keys.size-1).times { keys[keys.size-1] = ' ' + keys[keys.size-1] } #Add indentation for children keys
|
96
|
-
# y.puts(keys[keys.size-1]+':'+v+"\n")
|
97
|
-
# end
|
107
|
+
y.puts({ basename => data }.ya2yaml )
|
98
108
|
end
|
99
109
|
end
|
100
110
|
|
data/spec/i18n_sync_spec.rb
CHANGED
@@ -7,8 +7,16 @@ def run(comm)
|
|
7
7
|
`bin/i18s #{comm}`
|
8
8
|
end
|
9
9
|
|
10
|
+
def result(name)
|
11
|
+
File.read("spec/results/#{name}.yml")
|
12
|
+
end
|
13
|
+
|
14
|
+
def files_should_match(name, extra = nil)
|
15
|
+
File.read("spec/work#{extra}/#{name}.yml").should eql(result(name))
|
16
|
+
end
|
17
|
+
|
10
18
|
describe "I18nSync" do
|
11
|
-
before
|
19
|
+
before do
|
12
20
|
`rm -rf spec/work`
|
13
21
|
`cp -rf spec/fixtures spec/work`
|
14
22
|
end
|
@@ -40,6 +48,7 @@ describe "I18nSync" do
|
|
40
48
|
end
|
41
49
|
|
42
50
|
describe "Namespaced" do
|
51
|
+
|
43
52
|
let(:i) { I18S.new("spec/work/named.en.yml") }
|
44
53
|
|
45
54
|
it "should parse master file" do
|
@@ -50,20 +59,14 @@ describe "I18nSync" do
|
|
50
59
|
end
|
51
60
|
|
52
61
|
it "should read the hash" do
|
53
|
-
i.instance_variable_get("@words").
|
62
|
+
i.instance_variable_get("@words").
|
63
|
+
should eql({"something"=>"Something", "another"=>"Another"})
|
54
64
|
end
|
55
65
|
|
56
66
|
end
|
57
67
|
|
58
68
|
describe "Acceptance" do
|
59
69
|
|
60
|
-
it "should create a new one" do
|
61
|
-
newfile = "spec/work/fo.yml"
|
62
|
-
`rm #{newfile}` if File.exists?(newfile)
|
63
|
-
run("#{EN} fo")
|
64
|
-
File.read(newfile).should eql("# Comment cool\n--- \nfo: \n sync: \"To Sync It!\"\n test: Test\n")
|
65
|
-
end
|
66
|
-
|
67
70
|
it "should sync files nicely" do
|
68
71
|
run("spec/work/pt.yml")
|
69
72
|
File.read(EN).should eql("\n--- \nen: \n new: \"Uau, isso é novo\"\n sync: \"To Sync It!\"\n test: Test\n")
|
@@ -76,21 +79,71 @@ describe "I18nSync" do
|
|
76
79
|
|
77
80
|
it "should work with namespaces" do
|
78
81
|
run("spec/work/named.en.yml")
|
79
|
-
|
80
|
-
File.read("spec/work/pt.yml").
|
82
|
+
files_should_match("named.pt")
|
83
|
+
File.read("spec/work/pt.yml").
|
84
|
+
should eql("\npt:\n sync: To Sync It!\n test: Teste\n new: \"Uau, isso é novo\"\n")
|
81
85
|
end
|
82
86
|
|
83
87
|
it "should order alphabeticaly namespaces" do
|
84
88
|
run("spec/work/order.pt.yml")
|
85
|
-
|
89
|
+
files_should_match("order.en")
|
86
90
|
File.read("spec/work/named.pt.yml").should eql("\npt:\n something: Algo\n")
|
87
91
|
end
|
88
92
|
|
89
93
|
it "should work with extra chars" do
|
90
94
|
run("spec/work/extra.en.yml")
|
91
|
-
|
95
|
+
files_should_match("extra.pt")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should work with deep nestings" do
|
99
|
+
run("spec/work/children.en.yml")
|
100
|
+
files_should_match("children.pt")
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "Creating files" do
|
106
|
+
|
107
|
+
it "should create a new one" do
|
108
|
+
newfile = "spec/work/fo.yml"; `rm #{newfile}` if File.exists?(newfile)
|
109
|
+
run("#{EN} fo")
|
110
|
+
File.read(newfile).should eql("# Comment cool\n--- \nfo: \n sync: \"To Sync It!\"\n test: Test\n")
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should create a new with the right name" do
|
114
|
+
newfile = "spec/work/named.fo.yml"; `rm #{newfile}` if File.exists?(newfile)
|
115
|
+
run("spec/work/named.en.yml fo")
|
116
|
+
File.read(newfile).should eql("\n--- \nfo: \n another: Another\n something: Something\n")
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "Multi Files" do
|
122
|
+
|
123
|
+
before do
|
124
|
+
`rm -rf spec/workmulti`
|
125
|
+
`cp -rf spec/fixtures spec/workmulti`
|
92
126
|
end
|
93
127
|
|
128
|
+
it "should sync a show directory" do
|
129
|
+
run("spec/workmulti")
|
130
|
+
files_should_match("extra.pt", :multi)
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "Add keys to i18n!" do
|
136
|
+
|
137
|
+
it "should have a nice command to add stuff" do
|
138
|
+
run("add dynamic Dynamic spec/work/en.yml")
|
139
|
+
File.read("spec/work/en.yml").should eql("# Comment cool\n--- \nen: \n dynamic: Dynamic\n sync: \"To Sync It!\"\n test: Test\n")
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should work on a complex scenario" do
|
143
|
+
run("add dynamic.nested.very.nasty Nasty spec/work/extra.en.yml")
|
144
|
+
File.read("spec/work/extra.en.yml").should eql("\n--- \nen: \n dynamic: \n nested: \n very: \n nasty: Nasty\n normal: Normal\n with_colon: \"Value: Rock\"\n yup: true\n")
|
145
|
+
|
146
|
+
end
|
94
147
|
end
|
95
148
|
|
96
149
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Marcos Piccinini
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-06-06 00:00:00 -03:00
|
18
18
|
default_executable: i18s
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -39,10 +39,10 @@ dependencies:
|
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
segments:
|
42
|
-
- 1
|
43
42
|
- 2
|
44
|
-
-
|
45
|
-
|
43
|
+
- 5
|
44
|
+
- 0
|
45
|
+
version: 2.5.0
|
46
46
|
type: :development
|
47
47
|
version_requirements: *id002
|
48
48
|
description: Gem to sync all locale yml/rb files based on a "master" one.
|
@@ -63,6 +63,8 @@ files:
|
|
63
63
|
- bin/i18s
|
64
64
|
- i18n_sync.gemspec
|
65
65
|
- lib/i18n_sync.rb
|
66
|
+
- spec/fixtures/children.en.yml
|
67
|
+
- spec/fixtures/children.pt.yml
|
66
68
|
- spec/fixtures/en.yml
|
67
69
|
- spec/fixtures/extra.en.yml
|
68
70
|
- spec/fixtures/extra.pt.yml
|
@@ -72,6 +74,10 @@ files:
|
|
72
74
|
- spec/fixtures/order.pt.yml
|
73
75
|
- spec/fixtures/pt.yml
|
74
76
|
- spec/i18n_sync_spec.rb
|
77
|
+
- spec/results/children.pt.yml
|
78
|
+
- spec/results/extra.pt.yml
|
79
|
+
- spec/results/named.pt.yml
|
80
|
+
- spec/results/order.en.yml
|
75
81
|
- spec/spec_helper.rb
|
76
82
|
has_rdoc: true
|
77
83
|
homepage: http://github.com/nofxx/i18n_sync
|
@@ -105,6 +111,5 @@ rubygems_version: 1.3.7
|
|
105
111
|
signing_key:
|
106
112
|
specification_version: 3
|
107
113
|
summary: Syncs all locale yml/rb files based on a "master" one.
|
108
|
-
test_files:
|
109
|
-
|
110
|
-
- spec/spec_helper.rb
|
114
|
+
test_files: []
|
115
|
+
|