applocale 0.2.8 → 0.2.9
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.
- checksums.yaml +5 -5
- data/lib/applocale/AppLocaleFile +3 -2
- data/lib/applocale/Command/init.rb +0 -2
- data/lib/applocale/Core/ParseCSV/parse_csv.rb +23 -8
- data/lib/applocale/Core/ParseXLSX/parse_xlsx.rb +14 -6
- data/lib/applocale/Core/convert_to_localefile.rb +5 -24
- data/lib/applocale/Core/init.rb +3 -3
- data/lib/applocale/Core/setting.rb +1 -1
- data/lib/applocale/Util/config_util.rb +3 -0
- data/lib/applocale/Util/injection.rb +3 -2
- data/lib/applocale/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f480b988ac9b04365a14cfcc0fb6af05f80dc6ed57074df795115c4e65eccd66
|
4
|
+
data.tar.gz: 7ff2ea0fa652e029b3d54f1c97d8c22b8714f0ac15ad888d18b169263f075b7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14f9b9bfcd25af8df125c1914d4c658c134f921325c1d1ec5bfc073007f728124c8ea0b5b4454e2abd98be4322c77de43fa0a587976ae694c193c99efef402e8
|
7
|
+
data.tar.gz: 1a1214c98a866e60212b0d5a482009703f149abf91cd0221998eddf89655506bd62a8d9dbb5f1f72702067e302d96dcb62aa597ca721f4169cba798433d0dd70
|
data/lib/applocale/AppLocaleFile
CHANGED
@@ -18,16 +18,19 @@ module Applocale
|
|
18
18
|
@langlist
|
19
19
|
@sheetobj_list
|
20
20
|
@is_skip_empty_key
|
21
|
+
@injectobj
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
23
|
+
|
24
|
+
def initialize(setting)
|
25
|
+
@platform = setting.platform
|
26
|
+
@csv_directory = setting.export_to
|
27
|
+
@langlist = setting.lang_path_list
|
28
|
+
@sheetobj_list = setting.sheet_obj_list
|
27
29
|
@sheetcontent_list = Array.new
|
28
30
|
@allkey_dict = {}
|
29
31
|
@all_error = Array.new
|
30
|
-
@is_skip_empty_key = is_skip_empty_key
|
32
|
+
@is_skip_empty_key = setting.is_skip_empty_key
|
33
|
+
@injectobj = setting.injection
|
31
34
|
# puts "Start to Parse CSV: \"#{csv_directory}\" ...".green
|
32
35
|
parse
|
33
36
|
end
|
@@ -51,8 +54,18 @@ module Applocale
|
|
51
54
|
rows.each_with_index do |row, index|
|
52
55
|
next if sheet_content.header_rowno == index
|
53
56
|
row_content = parse_row(sheet_name, index, row, sheet_content.keyStr_with_colno, sheet_content.lang_with_colno_list)
|
54
|
-
|
55
|
-
|
57
|
+
next if row_content.nil?
|
58
|
+
toskip = false
|
59
|
+
if @injectobj.has_is_skip_by_key
|
60
|
+
is_skip_by_key = @injectobj.load_is_skip_by_key(sheet_name, row_content.key_str)
|
61
|
+
if is_skip_by_key.to_s.downcase == "true"
|
62
|
+
toskip = true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
if !toskip
|
66
|
+
handle_duplicate_key_if_any!(row_content)
|
67
|
+
sheet_content.rowinfo_list.push(row_content)
|
68
|
+
end
|
56
69
|
end
|
57
70
|
sheet_content
|
58
71
|
end
|
@@ -116,6 +129,8 @@ module Applocale
|
|
116
129
|
if (key_str.nil? || key_str.length == 0)
|
117
130
|
if !@is_skip_empty_key
|
118
131
|
raise "ParseCSVError: Key can not be empty, in sheet #{sheet_name}, row: #{index}, key_str: #{key_str}"
|
132
|
+
else
|
133
|
+
return
|
119
134
|
end
|
120
135
|
else
|
121
136
|
raise "ParseCSVError: Invaild Key in sheet #{sheet_name}, row: #{index}, key_str: #{key_str}"
|
@@ -24,17 +24,19 @@ module Applocale
|
|
24
24
|
@langlist
|
25
25
|
@sheetobj_list
|
26
26
|
@is_skip_empty_key
|
27
|
+
@injectobj
|
27
28
|
|
28
|
-
def initialize(
|
29
|
-
@platform =
|
30
|
-
@xlsxpath = xlsxpath
|
31
|
-
@langlist =
|
32
|
-
@sheetobj_list =
|
29
|
+
def initialize(setting)
|
30
|
+
@platform = setting.platform
|
31
|
+
@xlsxpath = setting.xlsxpath
|
32
|
+
@langlist = setting.lang_path_list
|
33
|
+
@sheetobj_list = setting.sheet_obj_list
|
33
34
|
puts "Start to Parse XLSX: \"#{@xlsxpath}\" ...".green
|
34
35
|
@sheetcontent_list = Array.new
|
35
36
|
@allkey_dict = {}
|
36
37
|
@all_error = Array.new
|
37
|
-
@is_skip_empty_key = is_skip_empty_key
|
38
|
+
@is_skip_empty_key = setting.is_skip_empty_key
|
39
|
+
@injectobj = setting.injection
|
38
40
|
self.parse
|
39
41
|
end
|
40
42
|
|
@@ -133,6 +135,12 @@ module Applocale
|
|
133
135
|
end
|
134
136
|
|
135
137
|
unless keystr.nil?
|
138
|
+
if @injectobj.has_is_skip_by_key
|
139
|
+
is_skip_by_key = @injectobj.load_is_skip_by_key(sheetname, keystr)
|
140
|
+
if is_skip_by_key.to_s.downcase == "true"
|
141
|
+
return nil
|
142
|
+
end
|
143
|
+
end
|
136
144
|
rowinfo = ParseModelModule::RowInfo.new(sheetname, rowno, keystr)
|
137
145
|
lang_with_colno_list.each do |lang_with_colno|
|
138
146
|
cell = cells[lang_with_colno.colno - 1]
|
@@ -9,9 +9,12 @@ require 'json'
|
|
9
9
|
module Applocale
|
10
10
|
class ConvertToStrFile
|
11
11
|
|
12
|
-
def self.convert(platform, lang_path_list, sheetcontent_list, rubycode)
|
13
12
|
|
14
|
-
|
13
|
+
def self.convert(setting, sheetcontent_list)
|
14
|
+
|
15
|
+
platform = setting.platform
|
16
|
+
lang_path_list = setting.lang_path_list
|
17
|
+
injectObj = setting.injection
|
15
18
|
|
16
19
|
lang_path_list.each do |langpath_obj|
|
17
20
|
puts "Start to convert to string file for [\"#{langpath_obj.lang}\"] #{langpath_obj.filepath}...".green
|
@@ -73,12 +76,6 @@ module Applocale
|
|
73
76
|
target.puts('')
|
74
77
|
contentlist.each do |rowinfo|
|
75
78
|
content = rowinfo.content_dict[langpath_obj.lang]
|
76
|
-
if injectObj.has_is_skip_by_key
|
77
|
-
is_skip_by_key = injectObj.load_is_skip_by_key(sheetcontent.sheetname, langpath_obj.lang, rowinfo.key_str)
|
78
|
-
if is_skip_by_key.to_s.downcase == "true"
|
79
|
-
next
|
80
|
-
end
|
81
|
-
end
|
82
79
|
value = self.add_escape(platform, langpath_obj.lang, rowinfo.key_str, content, injectObj)
|
83
80
|
target.puts("\"#{rowinfo.key_str}\" = \"#{value}\";")
|
84
81
|
end
|
@@ -95,12 +92,6 @@ module Applocale
|
|
95
92
|
contentlist = sheetcontent.get_rowInfo_sortby_key
|
96
93
|
contentlist.each do |rowinfo|
|
97
94
|
content = rowinfo.content_dict[langpath_obj.lang]
|
98
|
-
if injectObj.has_is_skip_by_key
|
99
|
-
is_skip_by_key = injectObj.load_is_skip_by_key(sheetcontent.sheetname, langpath_obj.lang, rowinfo.key_str)
|
100
|
-
if is_skip_by_key.to_s.downcase == "true"
|
101
|
-
next
|
102
|
-
end
|
103
|
-
end
|
104
95
|
value = self.add_escape(platform, langpath_obj.lang, rowinfo.key_str, content, injectObj)
|
105
96
|
target.puts(" <string name=\"#{rowinfo.key_str}\">#{value}</string>")
|
106
97
|
end
|
@@ -118,16 +109,6 @@ module Applocale
|
|
118
109
|
value = add_escape(platform, lang_path_obj.lang, row.key_str, content, inject_obj)
|
119
110
|
[row.key_str, value]
|
120
111
|
end.to_h
|
121
|
-
newResult = newResult.select do |key, value|
|
122
|
-
to_skip = false
|
123
|
-
if inject_obj.has_is_skip_by_key
|
124
|
-
is_skip_by_key = inject_obj.load_is_skip_by_key(sheet_content.sheetname, lang_path_obj.lang, key)
|
125
|
-
if is_skip_by_key.to_s.downcase == "true"
|
126
|
-
to_skip = true
|
127
|
-
end
|
128
|
-
end
|
129
|
-
!to_skip
|
130
|
-
end
|
131
112
|
newResult
|
132
113
|
end.reduce({}, :merge)
|
133
114
|
section_last_row = sheet_content_list
|
data/lib/applocale/Core/init.rb
CHANGED
@@ -68,11 +68,11 @@ module Applocale
|
|
68
68
|
end
|
69
69
|
case setting.export_format
|
70
70
|
when 'csv'
|
71
|
-
parser = Applocale::ParseCSV.new(setting
|
71
|
+
parser = Applocale::ParseCSV.new(setting)
|
72
72
|
when 'xlsx'
|
73
|
-
parser = Applocale::ParseXLSX.new(setting
|
73
|
+
parser = Applocale::ParseXLSX.new(setting)
|
74
74
|
end
|
75
|
-
ConvertToStrFile.convert(setting
|
75
|
+
ConvertToStrFile.convert(setting, parser.result)
|
76
76
|
end
|
77
77
|
|
78
78
|
def self.start_reverse( is_skip, projpath = Dir.pwd)
|
@@ -21,7 +21,7 @@ require 'colorize'
|
|
21
21
|
module Applocale
|
22
22
|
module Config
|
23
23
|
class Setting
|
24
|
-
attr_accessor :configfile_pathstr, :link, :platform, :xlsxpath, :google_credentials_path, :lang_path_list, :sheet_obj_list, :rubycode, :export_format, :export_to, :is_skip_empty_key
|
24
|
+
attr_accessor :configfile_pathstr, :link, :platform, :xlsxpath, :google_credentials_path, :lang_path_list, :sheet_obj_list, :rubycode, :export_format, :export_to, :is_skip_empty_key, :injection
|
25
25
|
def initialize(configfile_pathstr)
|
26
26
|
self.configfile_pathstr = configfile_pathstr
|
27
27
|
self.lang_path_list = Array.new
|
@@ -3,6 +3,7 @@ require File.expand_path('../file_util.rb', __FILE__)
|
|
3
3
|
require File.expand_path('../error_util.rb', __FILE__)
|
4
4
|
require File.expand_path('../platform.rb', __FILE__)
|
5
5
|
require File.expand_path('../../Core/setting.rb', __FILE__)
|
6
|
+
require File.expand_path('../injection.rb', __FILE__)
|
6
7
|
|
7
8
|
require 'pathname'
|
8
9
|
|
@@ -86,6 +87,8 @@ module Applocale
|
|
86
87
|
isSkipEmptyKey = config_yaml['isSkipEmptyKey']
|
87
88
|
setting = Applocale::Config::Setting.new(self.configfile_pathstr)
|
88
89
|
setting.rubycode = rubycode
|
90
|
+
setting.injection = Applocale::Injection.load(rubycode)
|
91
|
+
|
89
92
|
unless link.nil? || link.length == 0
|
90
93
|
if (link =~ /^https/).nil? && (link =~ /^http/).nil?
|
91
94
|
error = ErrorUtil::ConfigFileInValid.new("Invalid link for [link] : #{link}")
|
data/lib/applocale/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: applocale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kennix
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,9 +114,10 @@ dependencies:
|
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: 3.3.23
|
117
|
-
description: It can convert file between string
|
118
|
-
or csv from google. You can also setup
|
119
|
-
project. Support ios and
|
117
|
+
description: Applocale is a localization tool, It can convert file between string
|
118
|
+
and xlsx ,csv, also support download xlsx or csv from google. You can also setup
|
119
|
+
conversion logic for string value of each project. Support ios, android and json
|
120
|
+
format.
|
120
121
|
email:
|
121
122
|
- kennixdev@gmail.com
|
122
123
|
- johnwongapi@gmail.com
|
@@ -173,9 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
174
|
version: '0'
|
174
175
|
requirements: []
|
175
176
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.7.7
|
177
178
|
signing_key:
|
178
179
|
specification_version: 4
|
179
|
-
summary: for mobile application to manage
|
180
|
+
summary: for mobile application to manage localization
|
180
181
|
test_files: []
|
181
|
-
has_rdoc:
|