modpack_localizer 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +19 -16
- data/lib/modpack_localizer/jar/performer.rb +1 -1
- data/lib/modpack_localizer/jar/reader.rb +39 -1
- data/lib/modpack_localizer/util/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48bcad07e0c02e06435107cc2b8a39a37a3179eb7bcef64e7ac5db367c74f8da
|
4
|
+
data.tar.gz: d542c0869963484c4e394f399f04a762f4fc4cef47698f4b64d8157f74941eb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5a340bc8dcdd0619c0eb98e85d2cbd3354dbd99d77496ca4780594329fd9ac5c865c08f4aeec4ea3e12820e91b2362251c44859b4b01f0d15edc4bb1e196b78
|
7
|
+
data.tar.gz: 2315ad6a15de36bbc55a9941008c2a94b51725962e8c75878ba74e1bf912a51c44ae4ca3c366b2437dedbaba0b1df2b8a619b5e06cf080287ad0292126a8abe4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
## ModpackLocalizer
|
2
2
|
|
3
|
-
|
3
|
+
Localizer for Minecraft Modpack.
|
4
4
|
If you want to translate to other languages than Japanese,
|
5
5
|
please add the `language` option during initialization.
|
6
6
|
Can always get help with `ModpackLocalizer.help`
|
@@ -8,6 +8,7 @@ Can always get help with `ModpackLocalizer.help`
|
|
8
8
|
#### Example
|
9
9
|
|
10
10
|
`ModpackLocalizer::SNBT::Performer.new(language: "English")`
|
11
|
+
`ModpackLocalizer::JAR::Performer.new(language: "English")`
|
11
12
|
or if no specific configs required
|
12
13
|
`ModpackLocalizer.omakase(language: "English")`
|
13
14
|
|
@@ -18,62 +19,64 @@ or if no specific configs required
|
|
18
19
|
3. Add `OPENAI_API_KEY=your_api_key` to `.env`
|
19
20
|
4. Optional: Add `OPENAI_MODEL=some_openai_model` to `.env` **(default: gpt-4o-mini)**
|
20
21
|
5. Add `some.snbt` or `quests` directory contents to `quests` directory
|
21
|
-
6.
|
22
|
+
6. Add `some.jar` files to `mods` directory
|
23
|
+
7. Double click `start.bat` file
|
24
|
+
8. Check `output` directory
|
22
25
|
|
23
|
-
##
|
26
|
+
## Options for omakase method
|
24
27
|
|
25
28
|
#### language
|
26
29
|
|
27
|
-
Which language do you want to translate to?
|
30
|
+
Which language do you want to translate to?
|
28
31
|
**(default: Japanese)**
|
29
32
|
|
30
33
|
#### country
|
31
34
|
|
32
|
-
Your country name
|
35
|
+
Your country name
|
33
36
|
**(default: Japan)**
|
34
37
|
|
35
38
|
#### locale_code
|
36
39
|
|
37
40
|
Which locale code do you want to use?
|
38
|
-
If you specified this, you don't need to specify the country.
|
41
|
+
If you specified this, you don't need to specify the country.
|
39
42
|
**(default: nil)**
|
40
43
|
|
41
44
|
#### threadable
|
42
45
|
|
43
|
-
Do you want to exec in parallel?
|
46
|
+
Do you want to exec in parallel?
|
44
47
|
**(default: false)**
|
45
48
|
|
46
|
-
## Initialize
|
49
|
+
## Initialize options
|
47
50
|
|
48
51
|
#### output_logs
|
49
52
|
|
50
|
-
Want to output OpenAI usage logs?
|
53
|
+
Want to output OpenAI usage logs?
|
51
54
|
**(default: true)**
|
52
55
|
|
53
56
|
#### except_words
|
54
57
|
|
55
|
-
Words that you don't want to translate
|
58
|
+
Words that you don't want to translate
|
56
59
|
**(default: empty array)**
|
57
60
|
|
58
61
|
#### language
|
59
62
|
|
60
|
-
Which language do you want to translate to?
|
63
|
+
Which language do you want to translate to?
|
61
64
|
**(default: Japanese)**
|
62
65
|
|
63
66
|
#### display_help
|
64
67
|
|
65
|
-
Want to display help?
|
68
|
+
Want to display help?
|
66
69
|
**(default: true)**
|
67
70
|
|
68
|
-
## Only for jar performer
|
71
|
+
## Only for jar performer initialize options
|
69
72
|
|
70
73
|
#### country
|
71
74
|
|
72
|
-
Your country name
|
75
|
+
Your country name
|
73
76
|
**(default: Japan)**
|
74
77
|
|
75
78
|
#### locale_code
|
76
79
|
|
77
80
|
Which locale code do you want to use?
|
78
|
-
If you specified this, you don't need to specify the country.
|
79
|
-
**(default: nil)**
|
81
|
+
If you specified this, you don't need to specify the country.
|
82
|
+
**(default: nil)**
|
@@ -132,7 +132,7 @@ module ModpackLocalizer
|
|
132
132
|
return unless @loggable
|
133
133
|
|
134
134
|
@progress_bar.finish
|
135
|
-
|
135
|
+
puts lang_data.message || already_has_translated_file_message(lang_data)
|
136
136
|
end
|
137
137
|
|
138
138
|
# 既に翻訳済みのファイルが存在する旨のメッセージを出力する
|
@@ -9,6 +9,8 @@ module ModpackLocalizer
|
|
9
9
|
class Reader
|
10
10
|
# 例: ja_jp
|
11
11
|
LOCALE_CODE_REGEX = /\A[a-z]{2,3}_[a-z]{2,3}\z/
|
12
|
+
# BOM付きだとJSON.parseでエラーが出る
|
13
|
+
BOM_REGEX = /\A\xEF\xBB\xBF/
|
12
14
|
|
13
15
|
# performerに渡すレスポンス
|
14
16
|
#
|
@@ -60,7 +62,7 @@ module ModpackLocalizer
|
|
60
62
|
)
|
61
63
|
end
|
62
64
|
|
63
|
-
raw_json =
|
65
|
+
raw_json = parse_json(lang_file)
|
64
66
|
|
65
67
|
LangData.new(
|
66
68
|
true, except_comment(raw_json), lang_file, @locale_code, extract_mod_name(lang_file), nil
|
@@ -99,6 +101,42 @@ module ModpackLocalizer
|
|
99
101
|
lang_files.find { |entry| target_locale_file?(entry, locale_code) }
|
100
102
|
end
|
101
103
|
|
104
|
+
# JSONを解析する
|
105
|
+
# BOMを削除し、UTF-8に変換する
|
106
|
+
#
|
107
|
+
# @param [Zip::Entry] zip_entry ファイル
|
108
|
+
# @return [Hash] JSONのハッシュ
|
109
|
+
def parse_json(zip_entry)
|
110
|
+
content = read_inner_zip(zip_entry)
|
111
|
+
content = change_to_utf8(content)
|
112
|
+
content = remove_bom(content)
|
113
|
+
JSON.parse(content)
|
114
|
+
end
|
115
|
+
|
116
|
+
# zip内のファイルの内容を読み込む
|
117
|
+
#
|
118
|
+
# @param [Zip::Entry] zip_entry ファイル
|
119
|
+
# @return [String] ファイルの内容
|
120
|
+
def read_inner_zip(zip_entry)
|
121
|
+
zip_entry.get_input_stream.read
|
122
|
+
end
|
123
|
+
|
124
|
+
# BOMを削除する
|
125
|
+
#
|
126
|
+
# @param [String] str 文字列
|
127
|
+
# @return [String] BOMを削除した文字列
|
128
|
+
def remove_bom(str)
|
129
|
+
str.gsub(BOM_REGEX, "")
|
130
|
+
end
|
131
|
+
|
132
|
+
# UTF-8に変換する
|
133
|
+
#
|
134
|
+
# @param [String] str 文字列
|
135
|
+
# @return [String] UTF-8に変換した文字列
|
136
|
+
def change_to_utf8(str)
|
137
|
+
str.force_encoding("UTF-8")
|
138
|
+
end
|
139
|
+
|
102
140
|
# JSONからコメントを除外する
|
103
141
|
#
|
104
142
|
# @param [Hash] hash JSONのハッシュ
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modpack_localizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- milkeclair
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|