applyrics 0.0.3.pre → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/applyrics.rb +2 -0
- data/lib/applyrics/cli.rb +16 -5
- data/lib/applyrics/info.rb +1 -1
- data/lib/applyrics/languagefile.rb +4 -0
- data/lib/applyrics/project.rb +4 -0
- data/lib/applyrics/project_ios.rb +23 -3
- data/lib/applyrics/setup.rb +0 -4
- data/lib/applyrics/stringsfile.rb +32 -8
- data/lib/assets/LyricsfileTemplate +0 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5a8c442b98fb9151e37f70ec88480b448871054
|
4
|
+
data.tar.gz: cbed507f90c7651baf3225c941dc68f968766978
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e94add58e7b6b4615a94cfb242905499073290b7fb813a4cd4a1443e329a24f4ee0d4e61c9785c1118c4c808b551972b6e2c7d4b167f2cb79a50575c344e77a
|
7
|
+
data.tar.gz: 60ba3c94c66bbcd5fca2394a5be362c79a5148b071819430d51c411d321574bf7a3e768a87da966faea03b2d7c6fcade283004396818f73b5dec312871dba027
|
data/lib/applyrics.rb
CHANGED
data/lib/applyrics/cli.rb
CHANGED
@@ -16,9 +16,7 @@ module Applyrics
|
|
16
16
|
program :version, Applyrics::VERSION
|
17
17
|
program :description, Applyrics::DESCRIPTION
|
18
18
|
program :help_formatter, :compact
|
19
|
-
global_option '--project PATH', String, 'Path to iOS or Android project'
|
20
19
|
global_option '--[no-]rebuild', TrueClass, 'Rebuild language files from source'
|
21
|
-
global_option '--lang CODE', String, 'Only perform the action for the specified language'
|
22
20
|
|
23
21
|
command :init do |c|
|
24
22
|
c.syntax = "applyrics init"
|
@@ -55,7 +53,6 @@ module Applyrics
|
|
55
53
|
command :extract do |c|
|
56
54
|
c.syntax = "applyrics extract"
|
57
55
|
c.description = "Pull strings from the project into a strings.json file"
|
58
|
-
c.option '--force-split', TrueClass, 'Saves one language file per language instead of a single one for all languages'
|
59
56
|
c.action do |args, options|
|
60
57
|
|
61
58
|
project = Applyrics::Project.new()
|
@@ -85,8 +82,22 @@ module Applyrics
|
|
85
82
|
c.description = "Applies language from a .json file"
|
86
83
|
c.option '--data STRING', String, 'Path to .json file (Default: strings.json)'
|
87
84
|
c.action do |args, options|
|
88
|
-
options.default :project => './', :data => './
|
89
|
-
|
85
|
+
options.default :project => './', :data => './strings.json'
|
86
|
+
|
87
|
+
language_file = LanguageFile.new(options.data)
|
88
|
+
|
89
|
+
puts "Loaded language file with #{language_file.languages.length} languages".green
|
90
|
+
|
91
|
+
project = Applyrics::Project.new()
|
92
|
+
detect_lang = project.detected_languages
|
93
|
+
|
94
|
+
langs = project.string_files()
|
95
|
+
|
96
|
+
langs = langs.merge(language_file.to_hash)
|
97
|
+
|
98
|
+
project.apply_languages(langs)
|
99
|
+
|
100
|
+
|
90
101
|
end
|
91
102
|
end
|
92
103
|
|
data/lib/applyrics/info.rb
CHANGED
data/lib/applyrics/project.rb
CHANGED
@@ -36,7 +36,7 @@ module Applyrics
|
|
36
36
|
def language_files
|
37
37
|
folder = self.platform_project_settings("SOURCE_ROOT") unless !folder.nil?
|
38
38
|
out = {}
|
39
|
-
Dir[File.join(folder, "**","*.strings")].each do |file|
|
39
|
+
Dir[File.join(folder, "**", "*.lproj", "*.strings")].each do |file|
|
40
40
|
lang = /(\w*).lproj/.match(file)[1]
|
41
41
|
lang = (lang == "Base" ? default_language : lang)
|
42
42
|
|
@@ -76,12 +76,13 @@ module Applyrics
|
|
76
76
|
Dir[File.join(folder, "**", "*.lproj", "*.strings")].each do |file|
|
77
77
|
strings = StringsFile.new(file)
|
78
78
|
lang = /(\w*).lproj/.match(file)[1]
|
79
|
+
lang = (lang == "Base" ? default_language : lang)
|
79
80
|
|
80
81
|
if !out.key?(lang)
|
81
82
|
out[lang] = {}
|
82
83
|
end
|
83
84
|
|
84
|
-
out[lang][File.basename(file)] = strings.
|
85
|
+
out[lang][File.basename(file)] = strings.to_hash
|
85
86
|
end
|
86
87
|
|
87
88
|
out
|
@@ -105,12 +106,31 @@ module Applyrics
|
|
105
106
|
|
106
107
|
Dir[File.join(tmp_folder, "*.strings")].each do |file|
|
107
108
|
strings = StringsFile.new(file)
|
108
|
-
langHash[File.basename(file)] = strings.
|
109
|
+
langHash[File.basename(file)] = strings.to_hash
|
109
110
|
end
|
110
111
|
|
111
112
|
FileUtils.remove_dir(tmp_folder)
|
112
113
|
|
113
114
|
out
|
114
115
|
end
|
116
|
+
|
117
|
+
def apply_languages(data)
|
118
|
+
folder = self.platform_project_settings("SOURCE_ROOT")
|
119
|
+
|
120
|
+
data.each do |lang, files|
|
121
|
+
files.each do |file, data|
|
122
|
+
|
123
|
+
lang_folder = Dir[File.join(folder, "**", (lang == default_language ? "Base" : lang) + ".lproj")].first
|
124
|
+
|
125
|
+
if !Dir.exist?(lang_folder)
|
126
|
+
Dir.mkdir(lang_folder, 0700)
|
127
|
+
puts "Created #{lang_folder}".yellow
|
128
|
+
end
|
129
|
+
|
130
|
+
strings = StringsFile.new(File.join(lang_folder, file), data)
|
131
|
+
strings.write
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
115
135
|
end
|
116
136
|
end
|
data/lib/applyrics/setup.rb
CHANGED
@@ -7,16 +7,12 @@ module Applyrics
|
|
7
7
|
def run(config = {})
|
8
8
|
platform = nil
|
9
9
|
if is_ios?
|
10
|
-
puts "Found iOS project..."
|
11
10
|
platform = :ios
|
12
11
|
elsif is_android?
|
13
|
-
puts "Found Android project..."
|
14
12
|
platform = :android
|
15
13
|
elsif is_unity?
|
16
|
-
puts "Found Unity project..."
|
17
14
|
platform = :unity
|
18
15
|
else
|
19
|
-
puts "Didn't find any project!"
|
20
16
|
return
|
21
17
|
end
|
22
18
|
|
@@ -10,13 +10,6 @@ module Applyrics
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
def read
|
14
|
-
@hash = {}
|
15
|
-
parser = Parser.new(@hash)
|
16
|
-
File.open(@path, 'rb:bom|utf-16LE:utf-8') { |fd| parser.parse fd }
|
17
|
-
self
|
18
|
-
end
|
19
|
-
|
20
13
|
def keys
|
21
14
|
# Not implemented...
|
22
15
|
end
|
@@ -29,11 +22,42 @@ module Applyrics
|
|
29
22
|
# Not implemented...
|
30
23
|
end
|
31
24
|
|
32
|
-
def
|
25
|
+
def to_hash
|
33
26
|
@hash
|
34
27
|
end
|
35
28
|
|
29
|
+
def read
|
30
|
+
@hash = {}
|
31
|
+
parser = Parser.new(@hash)
|
32
|
+
File.open(@path, 'rb:bom|utf-16LE:utf-8') { |fd| parser.parse fd }
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
def write
|
37
|
+
temp = Tempfile.new(File.basename(@path))
|
38
|
+
begin
|
39
|
+
gen = Generator.new(@hash)
|
40
|
+
gen.run { |line| temp.puts line }
|
41
|
+
FileUtils.mv(temp.path, @path)
|
42
|
+
ensure
|
43
|
+
temp.close
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class Generator
|
48
|
+
def initialize(data)
|
49
|
+
@hash = data
|
50
|
+
end
|
51
|
+
|
52
|
+
def run
|
53
|
+
@hash.each do |key,value|
|
54
|
+
yield "\"#{key}\" = \"#{value}\"\n" if block_given?
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
36
59
|
class Parser
|
60
|
+
|
37
61
|
def initialize(hash)
|
38
62
|
@hash = hash
|
39
63
|
@property_regex = %r/\A(.*?)=(.*)\z/u
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: applyrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frederik Wallner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -153,12 +153,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
153
|
requirements:
|
154
154
|
- - '>='
|
155
155
|
- !ruby/object:Gem::Version
|
156
|
-
version: '
|
156
|
+
version: '1.9'
|
157
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
158
|
requirements:
|
159
|
-
- - '
|
159
|
+
- - '>='
|
160
160
|
- !ruby/object:Gem::Version
|
161
|
-
version:
|
161
|
+
version: '0'
|
162
162
|
requirements: []
|
163
163
|
rubyforge_project:
|
164
164
|
rubygems_version: 2.0.14
|