jp_quest 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -2
- data/CHANGELOG.md +9 -1
- data/README.md +3 -1
- data/dist/example.rb +5 -4
- data/lib/jp_quest/snbt/formatter.rb +34 -6
- data/lib/jp_quest/util/help.rb +4 -1
- data/lib/jp_quest/util/version.rb +1 -1
- data/lib/jp_quest.rb +9 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a05f6774d1670147f79ab786059cc3c97f04df0e84db66305b0718e13a8b96dd
|
4
|
+
data.tar.gz: 1217486377d6e7f7192eedfccb0bb6f9779936869856512848ad168a53db38f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d03ce663904e008ba3ce0d84ef7bf8dad63aa675a34465cc8eb1045f78fbc483c71fed190041477db79558aeddb2530040560d75252ede56ded77f0bb063bcb
|
7
|
+
data.tar.gz: bfc252135abc547c4acad3a76fc7ca13ebd3d332964a0423dbac1cea9cd279c7693aecae7841ff480c396d8a0a4966c63e9dd7a75d1b0a490112718ae03ac713
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,9 @@ Can always get help with `JpQuest.help`
|
|
7
7
|
|
8
8
|
#### Example
|
9
9
|
|
10
|
-
`JpQuest::SNBT::Performer.new(exchange_language: "English")`
|
10
|
+
`JpQuest::SNBT::Performer.new(exchange_language: "English")`
|
11
|
+
or if no specific configs required
|
12
|
+
`JpQuest.omakase(lang: "English")`
|
11
13
|
|
12
14
|
## Steps
|
13
15
|
|
data/dist/example.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
|
1
|
+
require "jp_quest"
|
2
2
|
|
3
3
|
performer = JpQuest::SNBT::Performer.new
|
4
4
|
|
5
|
-
|
6
|
-
#
|
5
|
+
file_path = "dist/quests/chapters/medium_eyes.snbt"
|
6
|
+
# file_path = "dist/dawncraft.snbt"
|
7
|
+
performer.perform(file_path)
|
7
8
|
|
8
|
-
performer.perform_directory
|
9
|
+
# performer.perform_directory
|
@@ -12,7 +12,7 @@ module JpQuest
|
|
12
12
|
# @param [String] indent インデント
|
13
13
|
# @return [String] SNBT形式に整形したコンテンツ
|
14
14
|
def format_overwritable_lines(content, indent)
|
15
|
-
full_lines =
|
15
|
+
full_lines = adjust_line_length(content)
|
16
16
|
format_for_snbt(full_lines, indent, content)
|
17
17
|
end
|
18
18
|
|
@@ -28,17 +28,16 @@ module JpQuest
|
|
28
28
|
"#{indent}#{content[:type]}: #{formatted_lines}"
|
29
29
|
end
|
30
30
|
|
31
|
-
#
|
31
|
+
# 行数をstart_line~end_lineと一致させる
|
32
32
|
#
|
33
33
|
# @param [Hash] content コンテンツ
|
34
34
|
# @return [void]
|
35
|
-
def
|
35
|
+
def adjust_line_length(content)
|
36
36
|
required_lines = extract_required_line_counts(content)
|
37
37
|
lines = content[:text].split("\n")
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
end
|
39
|
+
delete_over_lines(lines, required_lines)
|
40
|
+
add_missing_lines(lines, required_lines, content[:indent])
|
42
41
|
|
43
42
|
lines
|
44
43
|
end
|
@@ -88,6 +87,35 @@ module JpQuest
|
|
88
87
|
(content[:end_line] - content[:start_line]) + line_offset - without_brackets
|
89
88
|
end
|
90
89
|
|
90
|
+
# 不要な行を削除
|
91
|
+
#
|
92
|
+
# @param [Array<String>] lines 行
|
93
|
+
# @param [Integer] required_lines 必要な行数
|
94
|
+
# @return [void]
|
95
|
+
def delete_over_lines(lines, required_lines)
|
96
|
+
return unless lines.length > required_lines
|
97
|
+
|
98
|
+
gap_length = lines.length - required_lines
|
99
|
+
gap_length.times do
|
100
|
+
index = lines.index("")
|
101
|
+
lines.delete_at(index) if index
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# 不足している行を追加
|
106
|
+
#
|
107
|
+
# @param [Array<String>] lines 行
|
108
|
+
# @param [Integer] required_lines 必要な行数
|
109
|
+
# @param [String] indent インデント
|
110
|
+
# @return [void]
|
111
|
+
def add_missing_lines(lines, required_lines, indent)
|
112
|
+
return unless lines.length < required_lines
|
113
|
+
|
114
|
+
while lines.length < required_lines
|
115
|
+
lines << empty_middle_line(indent)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
91
119
|
# 中間行の空行を作成
|
92
120
|
#
|
93
121
|
# @return [String] 空行
|
data/lib/jp_quest/util/help.rb
CHANGED
@@ -36,7 +36,10 @@ module JpQuest
|
|
36
36
|
Translator for #{green(".snbt")} files.
|
37
37
|
If you want to translate to other languages than Japanese,
|
38
38
|
please add the #{green("exchange_language")} option during initialization.
|
39
|
-
Example:
|
39
|
+
Example:
|
40
|
+
#{green("JpQuest::SNBT::Performer.new(exchange_language: \"English\")")}
|
41
|
+
or if no specific configs required
|
42
|
+
#{green("JpQuest.omakase(lang: \"English\")")}
|
40
43
|
INTRO
|
41
44
|
end
|
42
45
|
|
data/lib/jp_quest.rb
CHANGED
@@ -11,6 +11,15 @@ require_relative "jp_quest/snbt/performer"
|
|
11
11
|
# - subtitle
|
12
12
|
# - description
|
13
13
|
module JpQuest
|
14
|
+
# quests以下のファイルを全て翻訳する
|
15
|
+
#
|
16
|
+
# @return [void]
|
17
|
+
def self.omakase(lang: "japanese")
|
18
|
+
performers = []
|
19
|
+
performers << JpQuest::SNBT::Performer.new(exchange_language: lang)
|
20
|
+
performers.each(&:perform_directory)
|
21
|
+
end
|
22
|
+
|
14
23
|
# JpQuest gemについてのヘルプを表示する
|
15
24
|
#
|
16
25
|
# @return [void]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jp_quest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- milkeclair
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jp_translator_from_gpt
|
@@ -91,7 +91,7 @@ metadata:
|
|
91
91
|
source_code_uri: https://github.com/milkeclair/jp_quest/blob/main
|
92
92
|
changelog_uri: https://github.com/milkeclair/jp_quest/blob/main/CHANGELOG.md
|
93
93
|
rubygems_mfa_required: 'true'
|
94
|
-
post_install_message:
|
94
|
+
post_install_message:
|
95
95
|
rdoc_options: []
|
96
96
|
require_paths:
|
97
97
|
- lib
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubygems_version: 3.5.21
|
110
|
-
signing_key:
|
110
|
+
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: translate to japanese for ftbquest
|
113
113
|
test_files: []
|