rabelyoda 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/LICENSE +20 -0
- data/README.markdown +30 -0
- data/VERSION +1 -0
- data/bin/rabelyoda +75 -0
- data/lib/rabelyoda/hash.rb +24 -0
- data/lib/rabelyoda/options.rb +42 -0
- metadata +104 -0
data/CHANGELOG
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
v1.0.0. Initial release.
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Andrey Subbotin
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
rabelyoda
|
2
|
+
=========
|
3
|
+
|
4
|
+
A simple utility to push/pull l10n resources of a Rails project to/from the translators.
|
5
|
+
|
6
|
+
How to Use
|
7
|
+
==========
|
8
|
+
|
9
|
+
cd your-rails-project-dir
|
10
|
+
rabelyoda
|
11
|
+
|
12
|
+
Checkout the `config/locales.out` folder for merged locale files. Each file, except the `en.yml`, will have new strings added with `[pls translate]` in the beginning.
|
13
|
+
|
14
|
+
All of the strings not found in `en.yml`, will be removed from `*.yml` as well.
|
15
|
+
|
16
|
+
Note on Patches/Pull Requests
|
17
|
+
=============================
|
18
|
+
|
19
|
+
* Fork the project.
|
20
|
+
* Make your feature addition or bug fix.
|
21
|
+
* Add tests for it. This is important so I don't break it in a
|
22
|
+
future version unintentionally.
|
23
|
+
* Commit, do not mess with rakefile, version, or history.
|
24
|
+
(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)
|
25
|
+
* Send me a pull request. Bonus points for topic branches.
|
26
|
+
|
27
|
+
Copyright
|
28
|
+
=========
|
29
|
+
|
30
|
+
Copyright (c) 2010 Andrey Subbotin. See LICENSE for details.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.1
|
data/bin/rabelyoda
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'term/ansicolor'
|
6
|
+
require 'tmpdir'
|
7
|
+
require 'yaml'
|
8
|
+
require 'ya2yaml'
|
9
|
+
$KCODE = 'UTF8'
|
10
|
+
|
11
|
+
include Term::ANSIColor
|
12
|
+
|
13
|
+
require 'rabelyoda/options'
|
14
|
+
require 'rabelyoda/hash'
|
15
|
+
|
16
|
+
# Main block
|
17
|
+
|
18
|
+
def main
|
19
|
+
$config = RabelYoda::Options.parse
|
20
|
+
|
21
|
+
load_ymls
|
22
|
+
populate_locales
|
23
|
+
save_ymls
|
24
|
+
|
25
|
+
success "All done!"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Aux methods
|
29
|
+
|
30
|
+
def exe(cmd) ; putcmd cmd ; system cmd ; end
|
31
|
+
def putcmd(cmd) ; print magenta, "CMD: #{cmd}", reset, "\n" ; end
|
32
|
+
def status(msg) ; print blue, "--- #{msg} ---", reset, "\n" ; end
|
33
|
+
def success(msg) ; print green, bold, 'SUCCESS: ', msg, reset, "\n" ; end
|
34
|
+
def error(msg) ; print red, bold, 'ERROR: ', msg, reset, "\n" ; exit 1 ; end
|
35
|
+
|
36
|
+
# Globbers
|
37
|
+
|
38
|
+
def all_ymls
|
39
|
+
Dir.glob(File.join('config', 'locales', '*.yml'))
|
40
|
+
end
|
41
|
+
|
42
|
+
def locale_for_yml_filename(yml_filename)
|
43
|
+
yml_filename.scan(/([^\/\.]+)\.yml/)[0].to_s
|
44
|
+
end
|
45
|
+
|
46
|
+
# Workers
|
47
|
+
|
48
|
+
def load_ymls
|
49
|
+
$locales = {}
|
50
|
+
all_ymls.each do |yml_filename|
|
51
|
+
locale_name = locale_for_yml_filename(yml_filename)
|
52
|
+
$locales[locale_name] = YAML::load_file(yml_filename)[locale_name]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def populate_locales
|
57
|
+
$locales.keys.each do |locale_name|
|
58
|
+
next if locale_name == 'en'
|
59
|
+
$locales[locale_name] = $locales['en'].locale_diff($locales[locale_name])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def save_ymls
|
64
|
+
FileUtils.mkdir_p File.join('config', 'locales.out'), :verbose => true
|
65
|
+
$locales.keys.each do |locale_name|
|
66
|
+
yml_filename = File.join('config', 'locales.out', "#{locale_name}.yml")
|
67
|
+
File.open(yml_filename, "w") do |file|
|
68
|
+
file.puts($locales[locale_name].ya2yaml)
|
69
|
+
end
|
70
|
+
status yml_filename
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
main
|
75
|
+
exit 0
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
class Hash
|
4
|
+
def locale_diff(b)
|
5
|
+
a = self
|
6
|
+
(a.keys | b.keys).inject({}) do |diff, k|
|
7
|
+
if a[k].respond_to?(:deep_diff) && b[k].respond_to?(:deep_diff)
|
8
|
+
deeper_diff = a[k].deep_diff(b[k])
|
9
|
+
diff[k] = deeper_diff if deeper_diff != {}
|
10
|
+
else
|
11
|
+
if !a.keys.include?(k)
|
12
|
+
# omit extra strings
|
13
|
+
# diff[k] = 'extra'
|
14
|
+
elsif !b.keys.include?(k)
|
15
|
+
diff[k] = '[pls translate]' + a[k]
|
16
|
+
else
|
17
|
+
# keep translated strings
|
18
|
+
diff[k] = b[k]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
diff
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
module RabelYoda
|
7
|
+
class Options
|
8
|
+
|
9
|
+
#
|
10
|
+
# Return a structure describing the options.
|
11
|
+
#
|
12
|
+
def self.parse
|
13
|
+
# The options specified on the command line will be collected in *options*.
|
14
|
+
# We set default values here.
|
15
|
+
options = { 'rules' => 'config/rabelyoda.yml' }
|
16
|
+
|
17
|
+
optparser = OptionParser.new do |opts|
|
18
|
+
opts.banner = "Usage: babelyoda [options]"
|
19
|
+
|
20
|
+
opts.separator ""
|
21
|
+
opts.separator "Common options:"
|
22
|
+
|
23
|
+
# Optional argument; multi-line description.
|
24
|
+
opts.on("-r", "--rules <RULES-FILE>",
|
25
|
+
"Use the specified rules file.",
|
26
|
+
"Default is 'config/rabelyoda.yml'.") do |rules|
|
27
|
+
options['rules'] = rules
|
28
|
+
end
|
29
|
+
|
30
|
+
# No argument, shows at tail. This will print an options summary.
|
31
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
32
|
+
puts opts
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
optparser.parse!
|
38
|
+
options
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rabelyoda
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Andrey Subbotin
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-23 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
- rabelyoda
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: plist
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: term-ansicolor
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
version: "0"
|
43
|
+
type: :runtime
|
44
|
+
version_requirements: *id002
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: ya2yaml
|
47
|
+
prerelease: false
|
48
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
type: :runtime
|
56
|
+
version_requirements: *id003
|
57
|
+
description: A simple utility to push/pull l10n resources of a Rails project to/from the translators
|
58
|
+
email: andrey@subbotin.me
|
59
|
+
executables:
|
60
|
+
- rabelyoda
|
61
|
+
extensions: []
|
62
|
+
|
63
|
+
extra_rdoc_files:
|
64
|
+
- LICENSE
|
65
|
+
- README.markdown
|
66
|
+
files:
|
67
|
+
- CHANGELOG
|
68
|
+
- LICENSE
|
69
|
+
- README.markdown
|
70
|
+
- VERSION
|
71
|
+
- lib/rabelyoda/hash.rb
|
72
|
+
- lib/rabelyoda/options.rb
|
73
|
+
has_rdoc: true
|
74
|
+
homepage: http://github.com/eploko/rabelyoda
|
75
|
+
licenses: []
|
76
|
+
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options:
|
79
|
+
- --charset=UTF-8
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
requirements: []
|
97
|
+
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.3.6
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: Rails project localization made easy
|
103
|
+
test_files: []
|
104
|
+
|