rvpacker-txt 1.11.0 → 1.13.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.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +20 -24
- data/bin/rvpacker-txt +184 -126
- data/lib/classes.rb +23 -62
- data/lib/extensions.rb +195 -199
- data/lib/read.rb +342 -362
- data/lib/write.rb +247 -187
- data/rvpacker-txt.gemspec +12 -2
- metadata +4 -4
- /data/{LICENSE → LICENSE.md} +0 -0
data/lib/read.rb
CHANGED
|
@@ -3,38 +3,39 @@
|
|
|
3
3
|
require 'zlib'
|
|
4
4
|
require_relative 'extensions'
|
|
5
5
|
|
|
6
|
-
STRING_IS_ONLY_SYMBOLS_RE =
|
|
6
|
+
STRING_IS_ONLY_SYMBOLS_RE =
|
|
7
|
+
%r{^[.()+\-:;\[\]^~%&!№$@`*/→×??x%▼|♥♪!:〜『』「」〽。…‥=゠、,【】[]{}()〔〕⦅⦆〘〙〈〉《》・\\#'"<>=_ー※▶ⅠⅰⅡⅱⅢⅲⅣⅳⅤⅴⅥⅵⅦⅶⅧⅷⅨⅸⅩⅹⅪⅺⅫⅻⅬⅼⅭⅽⅮⅾⅯⅿ\s0-9]+$}
|
|
7
8
|
APPEND_FLAG_OMIT_MSG = "Files aren't already parsed. Continuing as if --append flag was omitted."
|
|
8
9
|
|
|
9
10
|
# @param [Integer] code
|
|
10
11
|
# @param [String] parameter
|
|
11
12
|
# @param [String] game_type
|
|
12
|
-
# @return [String]
|
|
13
|
+
# @return [String | nil]
|
|
13
14
|
def self.parse_parameter(code, parameter, game_type)
|
|
14
15
|
return nil if parameter.match?(STRING_IS_ONLY_SYMBOLS_RE)
|
|
15
16
|
|
|
16
17
|
ends_with_if = parameter[/ if\(.*\)$/]
|
|
18
|
+
|
|
17
19
|
parameter = parameter.chomp(ends_with_if) if ends_with_if
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
if game_type
|
|
20
22
|
case game_type
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
else
|
|
31
|
-
return nil
|
|
32
|
-
end
|
|
33
|
-
# Implement cases for other games
|
|
23
|
+
when 'lisa'
|
|
24
|
+
case code
|
|
25
|
+
when 401, 405
|
|
26
|
+
prefix = parameter[/^(\\et\[[0-9]+\]|\\nbt)/]
|
|
27
|
+
parameter = parameter.sub(prefix, '') if prefix
|
|
28
|
+
when 102
|
|
29
|
+
# Implement some custom parsing
|
|
30
|
+
when 356
|
|
31
|
+
# Implement some custom parsing
|
|
34
32
|
else
|
|
35
|
-
nil
|
|
33
|
+
return nil
|
|
34
|
+
end
|
|
35
|
+
# Implement cases for other games
|
|
36
|
+
else
|
|
37
|
+
nil
|
|
36
38
|
end
|
|
37
|
-
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
parameter
|
|
@@ -49,36 +50,137 @@ def self.parse_variable(variable, type, _game_type)
|
|
|
49
50
|
# for some reason it returns true if multi-line string contains carriage returns (wtf?)
|
|
50
51
|
return nil if variable.match?(STRING_IS_ONLY_SYMBOLS_RE)
|
|
51
52
|
|
|
52
|
-
if variable.split("\n").all?
|
|
53
|
-
line.empty? ||
|
|
54
|
-
line.match?(/^#? ?<.*>.?$/) ||
|
|
55
|
-
line.match?(/^[a-z][0-9]$/)
|
|
56
|
-
end
|
|
53
|
+
if variable.split("\n").all? { |line| line.empty? || line.match?(/^#? ?<.*>.?$/) || line.match?(/^[a-z][0-9]$/) }
|
|
57
54
|
return nil
|
|
58
55
|
end
|
|
59
56
|
|
|
60
|
-
return nil if variable.match?(/^[+-]?[0-9]+$/) ||
|
|
61
|
-
variable.match?(/---/) ||
|
|
62
|
-
variable.match?(/restrict eval/)
|
|
57
|
+
return nil if variable.match?(/^[+-]?[0-9]+$/) || variable.match?(/---/) || variable.match?(/restrict eval/)
|
|
63
58
|
|
|
64
59
|
case type
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
when 0 # name
|
|
61
|
+
when 1 # nickname
|
|
62
|
+
when 2 # description
|
|
63
|
+
when 3 # note
|
|
64
|
+
else
|
|
65
|
+
nil
|
|
71
66
|
end
|
|
72
67
|
|
|
73
68
|
variable
|
|
74
69
|
end
|
|
75
70
|
|
|
71
|
+
# @param [Array<Object>] list
|
|
72
|
+
# @param [Array<Integer>] allowed_codes
|
|
73
|
+
# @param [Boolean] romanize
|
|
74
|
+
# @param [String] game_type
|
|
75
|
+
# @param [Symbol] processing_mode
|
|
76
|
+
# @param [Set<String>] set
|
|
77
|
+
# @param [Hash{String => String}] map
|
|
78
|
+
def self.parse_list(list, allowed_codes, romanize, game_type, processing_mode, set, map)
|
|
79
|
+
in_sequence = false
|
|
80
|
+
# @type [Array<String>]
|
|
81
|
+
line = []
|
|
82
|
+
|
|
83
|
+
list.each do |item|
|
|
84
|
+
# @type [Integer]
|
|
85
|
+
code = item.code
|
|
86
|
+
|
|
87
|
+
if in_sequence && ![401, 405].include?(code)
|
|
88
|
+
unless line.empty?
|
|
89
|
+
joined = line.join("\n").strip.gsub("\n", '\#')
|
|
90
|
+
parsed = parse_parameter(401, joined, game_type)
|
|
91
|
+
|
|
92
|
+
if parsed
|
|
93
|
+
parsed = romanize_string(parsed) if romanize
|
|
94
|
+
|
|
95
|
+
map.insert_at_index(set.length, parsed, '') if processing_mode == :append && !map.include?(parsed)
|
|
96
|
+
|
|
97
|
+
set.add(parsed)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
line.clear
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
in_sequence = false
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
next unless allowed_codes.include?(code)
|
|
107
|
+
|
|
108
|
+
# @type [Array<String>]
|
|
109
|
+
parameters = item.parameters
|
|
110
|
+
|
|
111
|
+
case code
|
|
112
|
+
when 401, 405
|
|
113
|
+
# @type [String]
|
|
114
|
+
parameter = parameters[0]
|
|
115
|
+
next unless parameter.is_a?(String)
|
|
116
|
+
|
|
117
|
+
parameter = convert_to_utf8(parameter)
|
|
118
|
+
|
|
119
|
+
in_sequence = true
|
|
120
|
+
line.push(parameter.gsub(' ', ' ').strip)
|
|
121
|
+
when 102
|
|
122
|
+
if parameters[0].is_a?(Array)
|
|
123
|
+
parameters[0].each do |subparameter|
|
|
124
|
+
next unless subparameter.is_a?(String)
|
|
125
|
+
|
|
126
|
+
subparameter = subparameter.strip
|
|
127
|
+
next if subparameter.empty?
|
|
128
|
+
|
|
129
|
+
subparameter = convert_to_utf8(subparameter)
|
|
130
|
+
parsed = parse_parameter(code, subparameter, game_type)
|
|
131
|
+
next unless parsed
|
|
132
|
+
|
|
133
|
+
parsed = romanize_string(parsed) if romanize
|
|
134
|
+
|
|
135
|
+
map.insert_at_index(set.length, parsed, '') if processing_mode == :append && !map.include?(parsed)
|
|
136
|
+
|
|
137
|
+
set.add(parsed)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
when 356
|
|
141
|
+
# @type [String]
|
|
142
|
+
parameter = parameters[0]
|
|
143
|
+
next unless parameter.is_a?(String)
|
|
144
|
+
|
|
145
|
+
parameter = parameter.strip
|
|
146
|
+
next if parameter.empty?
|
|
147
|
+
|
|
148
|
+
parameter = convert_to_utf8(parameter)
|
|
149
|
+
parsed = parse_parameter(code, parameter, game_type)
|
|
150
|
+
next unless parsed
|
|
151
|
+
|
|
152
|
+
parsed = romanize_string(parsed) if romanize
|
|
153
|
+
|
|
154
|
+
map.insert_at_index(set.length, parsed, '') if processing_mode == :append && !map.include?(parsed)
|
|
155
|
+
|
|
156
|
+
set.add(parsed)
|
|
157
|
+
when 320, 324
|
|
158
|
+
# @type [String]
|
|
159
|
+
parameter = parameters[1]
|
|
160
|
+
next unless parameter.is_a?(String)
|
|
161
|
+
|
|
162
|
+
parameter = parameter.strip
|
|
163
|
+
next if parameter.empty?
|
|
164
|
+
|
|
165
|
+
parameter = convert_to_utf8(parameter)
|
|
166
|
+
parsed = parse_parameter(code, parameter, game_type)
|
|
167
|
+
next unless parsed
|
|
168
|
+
|
|
169
|
+
parsed = romanize_string(parsed) if romanize
|
|
170
|
+
|
|
171
|
+
map.insert_at_index(set.length, parsed, '') if processing_mode == :append && !map.include?(parsed)
|
|
172
|
+
|
|
173
|
+
set.add(parsed)
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
76
178
|
# @param [Array<String>] maps_files_paths Array of paths to original maps files
|
|
77
179
|
# @param [String] output_path Path to output directory
|
|
78
180
|
# @param [Boolean] romanize Whether to romanize text
|
|
79
181
|
# @param [Boolean] logging Whether to log
|
|
80
182
|
# @param [String] game_type Game type for custom processing
|
|
81
|
-
# @param [
|
|
183
|
+
# @param [Symbol] processing_mode Whether to read in default mode, force rewrite or append new text to existing files
|
|
82
184
|
def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, processing_mode)
|
|
83
185
|
maps_output_path = File.join(output_path, 'maps.txt')
|
|
84
186
|
names_output_path = File.join(output_path, 'names.txt')
|
|
@@ -86,36 +188,51 @@ def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, p
|
|
|
86
188
|
names_trans_output_path = File.join(output_path, 'names_trans.txt')
|
|
87
189
|
|
|
88
190
|
if processing_mode == :default && (File.exist?(maps_trans_output_path) || File.exist?(names_trans_output_path))
|
|
89
|
-
puts 'maps_trans.txt or names_trans.txt file already exists. If you want to forcefully re-read all files,
|
|
191
|
+
puts 'maps_trans.txt or names_trans.txt file already exists. If you want to forcefully re-read all files, ' \
|
|
192
|
+
'use --force flag, or --append if you want append new text to already existing files.'
|
|
90
193
|
return
|
|
91
194
|
end
|
|
92
195
|
|
|
93
196
|
maps_object_map = Hash[maps_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
94
197
|
|
|
95
|
-
|
|
96
|
-
|
|
198
|
+
# @type [Set<String>]
|
|
199
|
+
maps_lines = Set.new
|
|
200
|
+
# @type [Set<String>]
|
|
201
|
+
names_lines = Set.new
|
|
97
202
|
|
|
98
|
-
|
|
99
|
-
|
|
203
|
+
# @type [Hash{String => String}]
|
|
204
|
+
maps_translation_map = {}
|
|
205
|
+
# @type [Hash{String => String}]
|
|
206
|
+
names_translation_map = {}
|
|
100
207
|
|
|
101
208
|
if processing_mode == :append
|
|
102
209
|
if File.exist?(maps_trans_output_path)
|
|
103
|
-
maps_translation_map =
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
210
|
+
maps_translation_map =
|
|
211
|
+
Hash[
|
|
212
|
+
File.readlines(maps_output_path, encoding: 'utf-8', chomp: true).zip(
|
|
213
|
+
File.readlines(maps_trans_output_path, encoding: 'utf-8', chomp: true),
|
|
214
|
+
)
|
|
215
|
+
]
|
|
216
|
+
names_translation_map =
|
|
217
|
+
Hash[
|
|
218
|
+
File.readlines(names_output_path, encoding: 'utf-8', chomp: true).zip(
|
|
219
|
+
File.readlines(names_trans_output_path, encoding: 'utf-8', chomp: true),
|
|
220
|
+
)
|
|
221
|
+
]
|
|
107
222
|
else
|
|
108
223
|
puts APPEND_FLAG_OMIT_MSG
|
|
109
224
|
processing_mode = :default
|
|
110
225
|
end
|
|
111
226
|
end
|
|
112
227
|
|
|
228
|
+
# @type [Array<Integer>]
|
|
113
229
|
# 401 - dialogue lines
|
|
114
230
|
# 102 - dialogue choices array
|
|
115
231
|
# 356 - system lines/special texts (do they even exist before mv?)
|
|
116
|
-
allowed_codes = [
|
|
232
|
+
allowed_codes = [102, 320, 324, 356, 401].freeze
|
|
117
233
|
|
|
118
234
|
maps_object_map.each do |filename, object|
|
|
235
|
+
# @type [String]
|
|
119
236
|
display_name = object.display_name
|
|
120
237
|
|
|
121
238
|
if display_name.is_a?(String)
|
|
@@ -124,110 +241,48 @@ def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, p
|
|
|
124
241
|
unless display_name.empty?
|
|
125
242
|
display_name = romanize_string(display_name) if romanize
|
|
126
243
|
|
|
127
|
-
|
|
128
|
-
|
|
244
|
+
if processing_mode == :append && !names_translation_map.include?(display_name)
|
|
245
|
+
names_translation_map.insert_at_index(names_lines.length, display_name, '')
|
|
246
|
+
end
|
|
129
247
|
|
|
130
248
|
names_lines.add(display_name)
|
|
131
249
|
end
|
|
132
250
|
end
|
|
133
251
|
|
|
134
252
|
events = object.events
|
|
135
|
-
next
|
|
253
|
+
next unless events
|
|
136
254
|
|
|
137
255
|
events.each_value do |event|
|
|
138
256
|
pages = event.pages
|
|
139
|
-
next
|
|
257
|
+
next unless pages
|
|
140
258
|
|
|
141
259
|
pages.each do |page|
|
|
142
260
|
list = page.list
|
|
143
|
-
next
|
|
144
|
-
|
|
145
|
-
in_sequence = false
|
|
146
|
-
line = []
|
|
147
|
-
|
|
148
|
-
list.each do |item|
|
|
149
|
-
code = item.code
|
|
150
|
-
|
|
151
|
-
if in_sequence && code != 401
|
|
152
|
-
unless line.empty?
|
|
153
|
-
joined = line.join("\n").strip.gsub("\n", '\#')
|
|
154
|
-
parsed = parse_parameter(401, joined, game_type)
|
|
155
|
-
|
|
156
|
-
unless parsed.nil?
|
|
157
|
-
parsed = romanize_string(parsed) if romanize
|
|
158
|
-
|
|
159
|
-
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_mode == :append &&
|
|
160
|
-
!maps_translation_map.include?(parsed)
|
|
161
|
-
|
|
162
|
-
maps_lines.add(parsed)
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
line.clear
|
|
167
|
-
in_sequence = false
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
next unless allowed_codes.include?(code)
|
|
171
|
-
|
|
172
|
-
parameters = item.parameters
|
|
173
|
-
|
|
174
|
-
if code == 401
|
|
175
|
-
next unless parameters[0].is_a?(String) && !parameters[0].empty?
|
|
176
|
-
|
|
177
|
-
in_sequence = true
|
|
178
|
-
line.push(parameters[0].gsub(' ', ' ').strip)
|
|
179
|
-
elsif parameters[0].is_a?(Array)
|
|
180
|
-
parameters[0].each do |subparameter|
|
|
181
|
-
next unless subparameter.is_a?(String)
|
|
182
|
-
|
|
183
|
-
subparameter = subparameter.strip
|
|
184
|
-
next if subparameter.empty?
|
|
185
|
-
|
|
186
|
-
parsed = parse_parameter(code, subparameter, game_type)
|
|
187
|
-
next if parsed.nil?
|
|
188
|
-
|
|
189
|
-
parsed = romanize_string(parsed) if romanize
|
|
190
|
-
|
|
191
|
-
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_mode == :append &&
|
|
192
|
-
!maps_translation_map.include?(parsed)
|
|
193
|
-
|
|
194
|
-
maps_lines.add(parsed)
|
|
195
|
-
end
|
|
196
|
-
elsif parameters[0].is_a?(String)
|
|
197
|
-
parameter = parameters[0].strip
|
|
198
|
-
next if parameter.empty?
|
|
261
|
+
next unless list
|
|
199
262
|
|
|
200
|
-
|
|
201
|
-
next if parsed.nil?
|
|
202
|
-
|
|
203
|
-
parsed = romanize_string(parsed) if romanize
|
|
204
|
-
|
|
205
|
-
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_mode == :append &&
|
|
206
|
-
!maps_translation_map.include?(parsed)
|
|
207
|
-
|
|
208
|
-
maps_lines.add(parsed)
|
|
209
|
-
end
|
|
210
|
-
end
|
|
263
|
+
parse_list(list, allowed_codes, romanize, game_type, processing_mode, maps_lines, maps_translation_map)
|
|
211
264
|
end
|
|
212
265
|
end
|
|
213
266
|
|
|
214
267
|
puts "Parsed #{filename}" if logging
|
|
215
268
|
end
|
|
216
269
|
|
|
217
|
-
maps_original_content,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
270
|
+
maps_original_content, maps_translated_content, names_original_content, names_translated_content =
|
|
271
|
+
if processing_mode == :append
|
|
272
|
+
[
|
|
273
|
+
maps_translation_map.keys.join("\n"),
|
|
274
|
+
maps_translation_map.values.join("\n"),
|
|
275
|
+
names_translation_map.keys.join("\n"),
|
|
276
|
+
names_translation_map.values.join("\n"),
|
|
277
|
+
]
|
|
278
|
+
else
|
|
279
|
+
[
|
|
280
|
+
maps_lines.join("\n"),
|
|
281
|
+
"\n" * (maps_lines.empty? ? 0 : maps_lines.length - 1),
|
|
282
|
+
names_lines.join("\n"),
|
|
283
|
+
"\n" * (names_lines.empty? ? 0 : names_lines.length - 1),
|
|
284
|
+
]
|
|
285
|
+
end
|
|
231
286
|
|
|
232
287
|
File.binwrite(maps_output_path, maps_original_content)
|
|
233
288
|
File.binwrite(maps_trans_output_path, maps_translated_content)
|
|
@@ -240,16 +295,18 @@ end
|
|
|
240
295
|
# @param [Boolean] romanize Whether to romanize text
|
|
241
296
|
# @param [Boolean] logging Whether to log
|
|
242
297
|
# @param [String] game_type Game type for custom processing
|
|
243
|
-
# @param [
|
|
298
|
+
# @param [Symbol] processing_mode Whether to read in default mode, force rewrite or append new text to existing files
|
|
244
299
|
def self.read_other(other_files_paths, output_path, romanize, logging, game_type, processing_mode)
|
|
245
300
|
other_object_array_map = Hash[other_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
246
301
|
|
|
247
|
-
|
|
302
|
+
inner_processing_mode = processing_mode
|
|
303
|
+
|
|
304
|
+
# @type [Array<Integer>]
|
|
248
305
|
# 401 - dialogue lines
|
|
249
306
|
# 405 - credits lines
|
|
250
307
|
# 102 - dialogue choices array
|
|
251
308
|
# 356 - system lines/special texts (do they even exist before mv?)
|
|
252
|
-
allowed_codes = [
|
|
309
|
+
allowed_codes = [102, 320, 324, 356, 401, 405].freeze
|
|
253
310
|
|
|
254
311
|
other_object_array_map.each do |filename, other_object_array|
|
|
255
312
|
processed_filename = File.basename(filename, '.*').downcase
|
|
@@ -258,160 +315,103 @@ def self.read_other(other_files_paths, output_path, romanize, logging, game_type
|
|
|
258
315
|
other_trans_output_path = File.join(output_path, "#{processed_filename}_trans.txt")
|
|
259
316
|
|
|
260
317
|
if processing_mode == :default && File.exist?(other_trans_output_path)
|
|
261
|
-
puts "#{processed_filename}_trans.txt file already exists. If you want to forcefully re-read all files,
|
|
318
|
+
puts "#{processed_filename}_trans.txt file already exists. If you want to forcefully re-read all files, ' \
|
|
319
|
+
'use --force flag, or --append if you want append new text to already existing files."
|
|
262
320
|
next
|
|
263
321
|
end
|
|
264
322
|
|
|
265
|
-
|
|
266
|
-
|
|
323
|
+
# @type [Set<String>]
|
|
324
|
+
other_lines = Set.new
|
|
325
|
+
# @type [Hash{String => String}]
|
|
326
|
+
other_translation_map = {}
|
|
267
327
|
|
|
268
328
|
if processing_mode == :append
|
|
269
329
|
if File.exist?(other_trans_output_path)
|
|
270
|
-
|
|
271
|
-
other_translation_map =
|
|
272
|
-
|
|
330
|
+
inner_processing_mode = :append
|
|
331
|
+
other_translation_map =
|
|
332
|
+
Hash[
|
|
333
|
+
File.readlines(other_output_path, encoding: 'utf-8', chomp: true).zip(
|
|
334
|
+
File.readlines(other_trans_output_path, encoding: 'utf-8', chomp: true),
|
|
335
|
+
)
|
|
336
|
+
]
|
|
273
337
|
else
|
|
274
338
|
puts APPEND_FLAG_OMIT_MSG
|
|
275
|
-
|
|
339
|
+
inner_processing_mode = :default
|
|
276
340
|
end
|
|
277
341
|
end
|
|
278
342
|
|
|
279
|
-
if !filename.
|
|
343
|
+
if !filename.match?(/^(Common|Troops)/)
|
|
280
344
|
other_object_array.each do |object|
|
|
281
|
-
next
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
345
|
+
next unless object
|
|
346
|
+
|
|
347
|
+
# @type [Array<String | nil>]
|
|
348
|
+
attributes = [
|
|
349
|
+
object.name,
|
|
350
|
+
object.is_a?(RPG::Actor) ? object.nickname : nil,
|
|
351
|
+
object.description,
|
|
352
|
+
object.note,
|
|
353
|
+
object.is_a?(RPG::Skill) || object.is_a?(RPG::State) ? object.message1 : nil,
|
|
354
|
+
object.is_a?(RPG::Skill) || object.is_a?(RPG::State) ? object.message2 : nil,
|
|
355
|
+
object.is_a?(RPG::State) ? object.message3 : nil,
|
|
356
|
+
object.is_a?(RPG::State) ? object.message4 : nil,
|
|
357
|
+
]
|
|
358
|
+
|
|
359
|
+
attributes.each_with_index do |var, type|
|
|
360
|
+
next unless var.is_a?(String)
|
|
361
|
+
|
|
362
|
+
var = var.strip
|
|
363
|
+
next if var.empty?
|
|
364
|
+
|
|
365
|
+
var = convert_to_utf8(var)
|
|
366
|
+
parsed = parse_variable(var, type, game_type)
|
|
367
|
+
|
|
368
|
+
unless parsed
|
|
369
|
+
break if type.zero?
|
|
370
|
+
next
|
|
371
|
+
end
|
|
301
372
|
|
|
302
|
-
|
|
303
|
-
|
|
373
|
+
parsed = romanize_string(parsed) if romanize
|
|
374
|
+
parsed = parsed.split("\n").map(&:strip).join('\#')
|
|
304
375
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
throw :next_object
|
|
308
|
-
end
|
|
376
|
+
if inner_processing_mode == :append && !other_translation_map.include?(parsed)
|
|
377
|
+
other_translation_map.insert_at_index(other_lines.length, parsed, '')
|
|
309
378
|
end
|
|
379
|
+
|
|
380
|
+
other_lines.add(parsed)
|
|
310
381
|
end
|
|
311
382
|
end
|
|
312
383
|
else
|
|
313
384
|
other_object_array.each do |object|
|
|
314
|
-
next
|
|
385
|
+
next unless object
|
|
315
386
|
|
|
316
387
|
pages = object.pages
|
|
317
|
-
pages_length = pages
|
|
388
|
+
pages_length = !pages ? 1 : pages.length
|
|
318
389
|
|
|
319
390
|
(0..pages_length).each do |i|
|
|
320
|
-
list = pages
|
|
321
|
-
next
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
parsed = parse_parameter(401, joined, game_type)
|
|
333
|
-
|
|
334
|
-
unless parsed.nil?
|
|
335
|
-
parsed = romanize_string(parsed) if romanize
|
|
336
|
-
|
|
337
|
-
other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
|
|
338
|
-
!other_translation_map.include?(parsed)
|
|
339
|
-
|
|
340
|
-
other_lines.add(parsed)
|
|
341
|
-
end
|
|
342
|
-
end
|
|
343
|
-
|
|
344
|
-
line.clear
|
|
345
|
-
in_sequence = false
|
|
346
|
-
end
|
|
347
|
-
|
|
348
|
-
next unless allowed_codes.include?(code)
|
|
349
|
-
|
|
350
|
-
parameters = item.parameters
|
|
351
|
-
|
|
352
|
-
if [401, 405].include?(code)
|
|
353
|
-
next unless parameters[0].is_a?(String) && !parameters[0].empty?
|
|
354
|
-
|
|
355
|
-
in_sequence = true
|
|
356
|
-
line.push(parameters[0].gsub(' ', ' ').strip)
|
|
357
|
-
elsif parameters[0].is_a?(Array)
|
|
358
|
-
parameters[0].each do |subparameter|
|
|
359
|
-
next unless subparameter.is_a?(String)
|
|
360
|
-
|
|
361
|
-
subparameter = subparameter.strip
|
|
362
|
-
next if subparameter.empty?
|
|
363
|
-
|
|
364
|
-
parsed = parse_parameter(code, subparameter, game_type)
|
|
365
|
-
next if parsed.nil?
|
|
366
|
-
|
|
367
|
-
parsed = romanize_string(parsed) if romanize
|
|
368
|
-
|
|
369
|
-
other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
|
|
370
|
-
!other_translation_map.include?(parsed)
|
|
371
|
-
|
|
372
|
-
other_lines.add(parsed)
|
|
373
|
-
end
|
|
374
|
-
elsif parameters[0].is_a?(String)
|
|
375
|
-
parameter = parameters[0].strip
|
|
376
|
-
next if parameter.empty?
|
|
377
|
-
|
|
378
|
-
parsed = parse_parameter(code, parameter, game_type)
|
|
379
|
-
next if parsed.nil?
|
|
380
|
-
|
|
381
|
-
parsed = romanize_string(parsed) if romanize
|
|
382
|
-
|
|
383
|
-
other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
|
|
384
|
-
!other_translation_map.include?(parsed)
|
|
385
|
-
|
|
386
|
-
other_lines.add(parsed)
|
|
387
|
-
elsif parameters[1].is_a?(String)
|
|
388
|
-
parameter = parameters[1].strip
|
|
389
|
-
next if parameter.empty?
|
|
390
|
-
|
|
391
|
-
parsed = parse_parameter(code, parameter, game_type)
|
|
392
|
-
next if parsed.nil?
|
|
393
|
-
|
|
394
|
-
parsed = romanize_string(parsed) if romanize
|
|
395
|
-
|
|
396
|
-
other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
|
|
397
|
-
!other_translation_map.include?(parsed)
|
|
398
|
-
|
|
399
|
-
other_lines.add(parsed)
|
|
400
|
-
end
|
|
401
|
-
end
|
|
391
|
+
list = !pages ? object.list : pages[i].instance_variable_get(:@list)
|
|
392
|
+
next unless list
|
|
393
|
+
|
|
394
|
+
parse_list(
|
|
395
|
+
list,
|
|
396
|
+
allowed_codes,
|
|
397
|
+
romanize,
|
|
398
|
+
game_type,
|
|
399
|
+
inner_processing_mode,
|
|
400
|
+
other_lines,
|
|
401
|
+
other_translation_map,
|
|
402
|
+
)
|
|
402
403
|
end
|
|
403
404
|
end
|
|
404
405
|
end
|
|
405
406
|
|
|
406
407
|
puts "Parsed #{filename}" if logging
|
|
407
408
|
|
|
408
|
-
original_content, translated_content =
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
end
|
|
409
|
+
original_content, translated_content =
|
|
410
|
+
if processing_mode == :append
|
|
411
|
+
[other_translation_map.keys.join("\n"), other_translation_map.values.join("\n")]
|
|
412
|
+
else
|
|
413
|
+
[other_lines.join("\n"), "\n" * (other_lines.empty? ? 0 : other_lines.length - 1)]
|
|
414
|
+
end
|
|
415
415
|
|
|
416
416
|
File.binwrite(other_output_path, original_content)
|
|
417
417
|
File.binwrite(other_trans_output_path, translated_content)
|
|
@@ -434,7 +434,7 @@ end
|
|
|
434
434
|
# @param [String] output_path
|
|
435
435
|
# @param [Boolean] romanize Whether to romanize text
|
|
436
436
|
# @param [Boolean] logging Whether to log
|
|
437
|
-
# @param [
|
|
437
|
+
# @param [Symbol] processing_mode Whether to read in default mode, force rewrite or append new text to existing files
|
|
438
438
|
def self.read_system(system_file_path, ini_file_path, output_path, romanize, logging, processing_mode)
|
|
439
439
|
system_filename = File.basename(system_file_path)
|
|
440
440
|
system_basename = File.basename(system_file_path, '.*').downcase
|
|
@@ -443,19 +443,26 @@ def self.read_system(system_file_path, ini_file_path, output_path, romanize, log
|
|
|
443
443
|
system_trans_output_path = File.join(output_path, "#{system_basename}_trans.txt")
|
|
444
444
|
|
|
445
445
|
if processing_mode == :default && File.exist?(system_trans_output_path)
|
|
446
|
-
puts 'system_trans.txt file already exists. If you want to forcefully re-read all files, use --force flag,
|
|
446
|
+
puts 'system_trans.txt file already exists. If you want to forcefully re-read all files, use --force flag, ' \
|
|
447
|
+
'or --append if you want append new text to already existing files.'
|
|
447
448
|
return
|
|
448
449
|
end
|
|
449
450
|
|
|
450
451
|
system_object = Marshal.load(File.binread(system_file_path))
|
|
451
452
|
|
|
452
|
-
|
|
453
|
-
|
|
453
|
+
# @type [Set<String>]
|
|
454
|
+
system_lines = Set.new
|
|
455
|
+
# @type [Hash{String => String}]
|
|
456
|
+
system_translation_map = {}
|
|
454
457
|
|
|
455
458
|
if processing_mode == :append
|
|
456
459
|
if File.exist?(system_trans_output_path)
|
|
457
|
-
system_translation_map =
|
|
458
|
-
|
|
460
|
+
system_translation_map =
|
|
461
|
+
Hash[
|
|
462
|
+
File.readlines(system_output_path, encoding: 'utf-8', chomp: true).zip(
|
|
463
|
+
File.readlines(system_trans_output_path, encoding: 'utf-8', chomp: true),
|
|
464
|
+
)
|
|
465
|
+
]
|
|
459
466
|
else
|
|
460
467
|
puts APPEND_FLAG_OMIT_MSG
|
|
461
468
|
processing_mode = :default
|
|
@@ -470,7 +477,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, romanize, log
|
|
|
470
477
|
terms = system_object.terms || system_object.words
|
|
471
478
|
|
|
472
479
|
[elements, skill_types, weapon_types, armor_types].each do |array|
|
|
473
|
-
next
|
|
480
|
+
next unless array
|
|
474
481
|
|
|
475
482
|
array.each do |string|
|
|
476
483
|
next unless string.is_a?(String)
|
|
@@ -478,10 +485,12 @@ def self.read_system(system_file_path, ini_file_path, output_path, romanize, log
|
|
|
478
485
|
string = string.strip
|
|
479
486
|
next if string.empty?
|
|
480
487
|
|
|
488
|
+
string = convert_to_utf8(string)
|
|
481
489
|
string = romanize_string(string) if romanize
|
|
482
490
|
|
|
483
|
-
|
|
484
|
-
|
|
491
|
+
if processing_mode == :append && !system_translation_map.include?(string)
|
|
492
|
+
system_translation_map.insert_at_index(system_lines.length, string, '')
|
|
493
|
+
end
|
|
485
494
|
|
|
486
495
|
system_lines.add(string)
|
|
487
496
|
end
|
|
@@ -491,10 +500,12 @@ def self.read_system(system_file_path, ini_file_path, output_path, romanize, log
|
|
|
491
500
|
currency_unit = currency_unit.strip
|
|
492
501
|
|
|
493
502
|
unless currency_unit.empty?
|
|
503
|
+
currency_unit = convert_to_utf8(currency_unit)
|
|
494
504
|
currency_unit = romanize_string(currency_unit) if romanize
|
|
495
505
|
|
|
496
|
-
|
|
497
|
-
|
|
506
|
+
if processing_mode == :append && !system_translation_map.include?(currency_unit)
|
|
507
|
+
system_translation_map.insert_at_index(system_lines.length, currency_unit, '')
|
|
508
|
+
end
|
|
498
509
|
|
|
499
510
|
system_lines.add(currency_unit)
|
|
500
511
|
end
|
|
@@ -507,10 +518,12 @@ def self.read_system(system_file_path, ini_file_path, output_path, romanize, log
|
|
|
507
518
|
value = value.strip
|
|
508
519
|
|
|
509
520
|
unless value.empty?
|
|
510
|
-
value =
|
|
521
|
+
value = convert_to_utf8(value)
|
|
522
|
+
value = romanize_string(value) if romanize
|
|
511
523
|
|
|
512
|
-
|
|
513
|
-
|
|
524
|
+
if processing_mode == :append && !system_translation_map.include?(value)
|
|
525
|
+
system_translation_map.insert_at_index(system_lines.length, value, '')
|
|
526
|
+
end
|
|
514
527
|
|
|
515
528
|
system_lines.add(value)
|
|
516
529
|
end
|
|
@@ -521,35 +534,38 @@ def self.read_system(system_file_path, ini_file_path, output_path, romanize, log
|
|
|
521
534
|
string = string.strip
|
|
522
535
|
next if string.empty?
|
|
523
536
|
|
|
537
|
+
string = convert_to_utf8(string)
|
|
524
538
|
string = romanize_string(string) if romanize
|
|
525
539
|
|
|
526
|
-
|
|
527
|
-
|
|
540
|
+
if processing_mode == :append && !system_translation_map.include?(string)
|
|
541
|
+
system_translation_map.insert_at_index(system_lines.length, string, '')
|
|
542
|
+
end
|
|
528
543
|
|
|
529
544
|
system_lines.add(string)
|
|
530
545
|
end
|
|
531
546
|
end
|
|
532
547
|
end
|
|
533
548
|
|
|
534
|
-
# Game title from System file and ini file may differ, but requesting user request to determine which line do they
|
|
549
|
+
# Game title from System file and ini file may differ, but requesting user request to determine which line do they
|
|
550
|
+
# want is LAME
|
|
535
551
|
# So just throw that ini ass and continue
|
|
536
552
|
ini_game_title = read_ini_title(ini_file_path).strip
|
|
537
553
|
ini_game_title = romanize_string(ini_game_title) if romanize
|
|
538
554
|
|
|
539
|
-
|
|
540
|
-
|
|
555
|
+
if processing_mode == :append && !system_translation_map.include?(ini_game_title)
|
|
556
|
+
system_translation_map.insert_at_index(system_lines.length, ini_game_title, '')
|
|
557
|
+
end
|
|
541
558
|
|
|
542
559
|
system_lines.add(ini_game_title)
|
|
543
560
|
|
|
544
561
|
puts "Parsed #{system_filename}" if logging
|
|
545
562
|
|
|
546
|
-
original_content, translated_content =
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
end
|
|
563
|
+
original_content, translated_content =
|
|
564
|
+
if processing_mode == :append
|
|
565
|
+
[system_translation_map.keys.join("\n"), system_translation_map.values.join("\n")]
|
|
566
|
+
else
|
|
567
|
+
[system_lines.join("\n"), "\n" * (system_lines.empty? ? 0 : system_lines.length - 1)]
|
|
568
|
+
end
|
|
553
569
|
|
|
554
570
|
File.binwrite(system_output_path, original_content)
|
|
555
571
|
File.binwrite(system_trans_output_path, translated_content)
|
|
@@ -559,7 +575,7 @@ end
|
|
|
559
575
|
# @param [String] output_path
|
|
560
576
|
# @param [Boolean] romanize Whether to romanize text
|
|
561
577
|
# @param [Boolean] logging Whether to log
|
|
562
|
-
# @param [
|
|
578
|
+
# @param [Symbol] processing_mode Whether to read in default mode, force rewrite or append new text to existing files
|
|
563
579
|
def self.read_scripts(scripts_file_path, output_path, romanize, logging, processing_mode)
|
|
564
580
|
scripts_filename = File.basename(scripts_file_path)
|
|
565
581
|
scripts_basename = File.basename(scripts_file_path, '.*').downcase
|
|
@@ -569,116 +585,80 @@ def self.read_scripts(scripts_file_path, output_path, romanize, logging, process
|
|
|
569
585
|
scripts_trans_output_path = File.join(output_path, "#{scripts_basename}_trans.txt")
|
|
570
586
|
|
|
571
587
|
if processing_mode == :default && File.exist?(scripts_trans_output_path)
|
|
572
|
-
puts 'scripts_trans.txt file already exists. If you want to forcefully re-read all files, use --force flag,
|
|
588
|
+
puts 'scripts_trans.txt file already exists. If you want to forcefully re-read all files, use --force flag, ' \
|
|
589
|
+
'or --append if you want append new text to already existing files.'
|
|
573
590
|
return
|
|
574
591
|
end
|
|
575
592
|
|
|
576
593
|
script_entries = Marshal.load(File.binread(scripts_file_path))
|
|
577
594
|
|
|
578
|
-
|
|
579
|
-
|
|
595
|
+
# @type [Set<String>]
|
|
596
|
+
scripts_lines = Set.new
|
|
597
|
+
# @type [Hash{String => String}]
|
|
598
|
+
scripts_translation_map = {}
|
|
580
599
|
|
|
581
600
|
if processing_mode == :append
|
|
582
601
|
if File.exist?(scripts_trans_output_path)
|
|
583
|
-
scripts_translation_map =
|
|
584
|
-
|
|
602
|
+
scripts_translation_map =
|
|
603
|
+
Hash[
|
|
604
|
+
File.readlines(scripts_output_path, encoding: 'utf-8', chomp: true).zip(
|
|
605
|
+
File.readlines(scripts_trans_output_path, encoding: 'utf-8', chomp: true),
|
|
606
|
+
)
|
|
607
|
+
]
|
|
585
608
|
else
|
|
586
609
|
puts APPEND_FLAG_OMIT_MSG
|
|
587
610
|
processing_mode = :default
|
|
588
611
|
end
|
|
589
612
|
end
|
|
590
613
|
|
|
614
|
+
# @type [Array<String>]
|
|
591
615
|
codes_content = []
|
|
592
616
|
|
|
593
617
|
# This code was fun before `that` game used Windows-1252 degree symbol
|
|
594
618
|
script_entries.each do |script|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
unless code.valid_encoding?
|
|
601
|
-
[Encoding::UTF_8, Encoding::WINDOWS_1252, Encoding::SHIFT_JIS].each do |encoding|
|
|
602
|
-
encoded = code.encode(code.encoding, encoding)
|
|
603
|
-
|
|
604
|
-
if encoded.valid_encoding?
|
|
605
|
-
code.force_encoding(encoding)
|
|
606
|
-
break
|
|
607
|
-
end
|
|
608
|
-
rescue Encoding::InvalidByteSequenceError
|
|
609
|
-
next
|
|
610
|
-
end
|
|
611
|
-
end
|
|
619
|
+
# @type [String]
|
|
620
|
+
code = Zlib::Inflate.inflate(script[2])
|
|
621
|
+
code = convert_to_utf8(code)
|
|
622
|
+
codes_content.push(code)
|
|
623
|
+
end
|
|
612
624
|
|
|
613
|
-
|
|
614
|
-
# Removes the U+3000 Japanese typographical space to check if string, when stripped, is truly empty
|
|
615
|
-
string = string.strip.delete(' ')
|
|
625
|
+
extracted = extract_strings(codes_content.join)
|
|
616
626
|
|
|
617
|
-
|
|
627
|
+
extracted.each do |string|
|
|
628
|
+
# Removes the U+3000 Japanese typographical space to check if string, when stripped, is truly empty
|
|
629
|
+
string = string.gsub(' ', ' ').strip
|
|
618
630
|
|
|
619
|
-
|
|
620
|
-
next if string.start_with?(/([#!?$@]|(\.\/)?(Graphics|Data|Audio|CG|Movies|Save)\/)/) ||
|
|
621
|
-
string.match?(/^[^\p{L}]+$/) ||
|
|
622
|
-
string.match?(/^\d+$/) ||
|
|
623
|
-
string.match?(/%.*(\d|\+|\*)d\]?:?$/) ||
|
|
624
|
-
string.match?(/^\[((ON|OFF)|P[EMRT])\]$/) ||
|
|
625
|
-
string.match?(/^\[\]$/) ||
|
|
626
|
-
string.match?(/^(.)\1{2,}$/) ||
|
|
627
|
-
string.match?(/^(false|true)$/) ||
|
|
628
|
-
string.match?(/^[wr]b$/) ||
|
|
629
|
-
string.match?(/^(?=.*\d)[A-Za-z0-9-]+$/) ||
|
|
630
|
-
string.match?(/^[a-z\-()\/ +'&]*$/) ||
|
|
631
|
-
string.match?(/^[A-Za-z]+[+-]$/) ||
|
|
632
|
-
string.match?(STRING_IS_ONLY_SYMBOLS_RE) ||
|
|
633
|
-
string.match?(/^Tile.*[A-Z]$/) ||
|
|
634
|
-
string.match?(/^[a-zA-Z][a-z]+([A-Z][a-z]*)+$/) ||
|
|
635
|
-
string.match?(/^Cancel Action$|^Invert$|^End$|^Individual$|^Missed File$|^Bitmap$|^Audio$/) ||
|
|
636
|
-
string.match?(/^(?=.*%d)(?=.*%m)(?=.*%Y).*$/) ||
|
|
637
|
-
string.match?(/^\\\\ALPHAC/) ||
|
|
638
|
-
string.match?(/^[A-Z]{,3}-[A-Z][A-Za-z]+/) ||
|
|
639
|
-
string.match?(/\.(mp3|ogg|jpg|png|ini|txt)$/i) ||
|
|
640
|
-
string.match?(/\/(\d.*)?$/) ||
|
|
641
|
-
string.match?(/FILE$/) ||
|
|
642
|
-
string.match?(/#\{/) ||
|
|
643
|
-
string.match?(/(?<!\\)\\(?![\\G#])/) ||
|
|
644
|
-
string.match?(/\+?=?=/) ||
|
|
645
|
-
string.match?(/[}{_<>]/) ||
|
|
646
|
-
string.match?(/r[vx]data/) ||
|
|
647
|
-
string.match?(/No such file or directory/) ||
|
|
648
|
-
string.match?(/level \*\*/) ||
|
|
649
|
-
string.match?(/Courier New|Comic Sans|Lucida|Verdana|Tahoma|Arial|Times New Roman/) ||
|
|
650
|
-
string.match?(/Player start location/) ||
|
|
651
|
-
string.match?(/Common event call has exceeded/) ||
|
|
652
|
-
string.match?(/se-/) ||
|
|
653
|
-
string.match?(/Start Pos/) ||
|
|
654
|
-
string.match?(/An error has occurred/) ||
|
|
655
|
-
string.match?(/Define it first/) ||
|
|
656
|
-
string.match?(/Process Skill/) ||
|
|
657
|
-
string.match?(/Wpn Only/) ||
|
|
658
|
-
string.match?(/Don't Wait/) ||
|
|
659
|
-
string.match?(/Clear image/) ||
|
|
660
|
-
string.match?(/Can Collapse/)
|
|
631
|
+
next if string.empty?
|
|
661
632
|
|
|
662
|
-
|
|
633
|
+
if string.match?(%r{(Graphics|Data|Audio|Movies|System)/.*/?}) || string.match?(/r[xv]data2?$/) ||
|
|
634
|
+
string.match?(STRING_IS_ONLY_SYMBOLS_RE) || string.match?(/@window/) || string.match?(/\$game/) ||
|
|
635
|
+
string.match?(/_/) || string.match?(/^\\e/) || string.match?(/.*\(/) ||
|
|
636
|
+
string.match?(/^([d\d\p{P}+-]*|[d\p{P}+-]*)$/) || string.match?(/ALPHAC/) ||
|
|
637
|
+
string.match?(
|
|
638
|
+
/^(Actor<id>|ExtraDropItem|EquipLearnSkill|GameOver|Iconset|Window|true|false|MActor%d|[wr]b|\\f|\\n|\[[A-Z]*\])$/,
|
|
639
|
+
)
|
|
640
|
+
next
|
|
641
|
+
end
|
|
663
642
|
|
|
664
|
-
|
|
665
|
-
!scripts_translation_map.include?(string)
|
|
643
|
+
string = romanize_string(string) if romanize
|
|
666
644
|
|
|
667
|
-
|
|
645
|
+
if processing_mode == :append && !scripts_translation_map.include?(string)
|
|
646
|
+
scripts_translation_map.insert_at_index(scripts_lines.length, string, '')
|
|
668
647
|
end
|
|
648
|
+
|
|
649
|
+
scripts_lines.add(string)
|
|
669
650
|
end
|
|
670
651
|
|
|
671
652
|
puts "Parsed #{scripts_filename}" if logging
|
|
672
653
|
|
|
673
654
|
File.binwrite(scripts_plain_output_path, codes_content.join("\n"))
|
|
674
655
|
|
|
675
|
-
original_content, translated_content =
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
end
|
|
656
|
+
original_content, translated_content =
|
|
657
|
+
if processing_mode == :append
|
|
658
|
+
[scripts_translation_map.keys.join("\n"), scripts_translation_map.values.join("\n")]
|
|
659
|
+
else
|
|
660
|
+
[scripts_lines.join("\n"), "\n" * (scripts_lines.empty? ? 0 : scripts_lines.length - 1)]
|
|
661
|
+
end
|
|
682
662
|
|
|
683
663
|
File.binwrite(scripts_output_path, original_content)
|
|
684
664
|
File.binwrite(scripts_trans_output_path, translated_content)
|