modpack_localizer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.licensed.yml +10 -0
- data/.rspec +3 -0
- data/.rubocop.yml +52 -0
- data/CHANGELOG.md +43 -0
- data/CODE_OF_CONDUCT.md +128 -0
- data/LICENSE.txt +21 -0
- data/README.md +79 -0
- data/Rakefile +39 -0
- data/dist/Gemfile +3 -0
- data/dist/example.rb +10 -0
- data/dist/start.bat +4 -0
- data/lib/modpack_localizer/jar/performer.rb +147 -0
- data/lib/modpack_localizer/jar/reader.rb +158 -0
- data/lib/modpack_localizer/jar/writer.rb +121 -0
- data/lib/modpack_localizer/snbt/description_extractor.rb +118 -0
- data/lib/modpack_localizer/snbt/formatter.rb +196 -0
- data/lib/modpack_localizer/snbt/performer.rb +92 -0
- data/lib/modpack_localizer/snbt/reader.rb +102 -0
- data/lib/modpack_localizer/snbt/subtitle_extractor.rb +32 -0
- data/lib/modpack_localizer/snbt/title_extractor.rb +32 -0
- data/lib/modpack_localizer/snbt/writer.rb +74 -0
- data/lib/modpack_localizer/util/error.rb +47 -0
- data/lib/modpack_localizer/util/help.rb +156 -0
- data/lib/modpack_localizer/util/indent_helper.rb +28 -0
- data/lib/modpack_localizer/util/version.rb +5 -0
- data/lib/modpack_localizer.rb +66 -0
- data/rake_helper.rb +29 -0
- data/sig/jp_quest.rbs +4 -0
- metadata +187 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 63164205d4e90427704614b77f5914731d2e12668e75ab278285c4b97cf8751d
|
4
|
+
data.tar.gz: fd7e1da351403590e3fff279007e35564400a497b58c525070dcd32374c182d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 43d4533823a00d98e9fff70649ef1138581c0dc456fc7fa24341517adf0606570a06b62e5495c98dbc2781149974f5a51722116a7cfd65985f7aae521df4781f
|
7
|
+
data.tar.gz: 910c218922001d64db4d9cb5e4b865ecd7b7351178f0a9365a51a1591be781b3e1272a5439499eb49781c015bc865df8294c5508e37806fbb2792ceada70f533
|
data/.licensed.yml
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 3.0
|
3
|
+
NewCops: enable
|
4
|
+
Exclude:
|
5
|
+
- "bin/**/*"
|
6
|
+
|
7
|
+
Style/StringLiterals:
|
8
|
+
EnforcedStyle: double_quotes
|
9
|
+
|
10
|
+
Style/StringLiteralsInInterpolation:
|
11
|
+
EnforcedStyle: double_quotes
|
12
|
+
|
13
|
+
Style/Documentation:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/ParallelAssignment:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Metrics/MethodLength:
|
20
|
+
CountComments: true
|
21
|
+
Max: 20
|
22
|
+
|
23
|
+
Lint/ScriptPermission:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Style/FetchEnvVar:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
RSpec/ExampleLength:
|
30
|
+
Max: 10
|
31
|
+
|
32
|
+
Style/FrozenStringLiteralComment:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Lint/EmptyFile:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
RSpec/BeNil:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
Style/RaiseArgs:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Style/WhileUntilModifier:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
Metrics/ParameterLists:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
require:
|
51
|
+
- rubocop-rake
|
52
|
+
- rubocop-rspec
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
## [Unreleased]
|
2
|
+
|
3
|
+
## [0.1.0] - 2024-10-03
|
4
|
+
|
5
|
+
- Initial release
|
6
|
+
|
7
|
+
## [0.1.1] - 2024-10/8
|
8
|
+
|
9
|
+
- バグ修正
|
10
|
+
|
11
|
+
## [0.1.2] - 2024-10/8
|
12
|
+
|
13
|
+
- 再帰的に処理できていなかったのを修正
|
14
|
+
|
15
|
+
## [0.1.3] - 2024-10/8
|
16
|
+
|
17
|
+
- バグ修正
|
18
|
+
|
19
|
+
## [0.2.0] - 2024-10/9
|
20
|
+
|
21
|
+
- 出力時のダブルクオート数、インデント数が崩れていたのを出来るだけ抑制
|
22
|
+
- quests.snbtのパス名も変換されていたのを修正
|
23
|
+
|
24
|
+
## [0.2.1] - 2024-10/10
|
25
|
+
|
26
|
+
- \と;を削除する記号に追加
|
27
|
+
|
28
|
+
## [0.3.0] - 2024-10/12
|
29
|
+
|
30
|
+
- MODの翻訳機能を追加しやすいように、モジュールの構造を変更
|
31
|
+
|
32
|
+
## [0.3.1] - 2024-10/25
|
33
|
+
|
34
|
+
- 不要な空行が追加されるバグを修正
|
35
|
+
|
36
|
+
## [0.3.2] - 2024-10/25
|
37
|
+
|
38
|
+
- 簡単に実行するためのオプションを追加
|
39
|
+
|
40
|
+
## [0.1.0] -2024-11/9
|
41
|
+
|
42
|
+
- 名前をJpQuest -> ModpackLocalizerに変更
|
43
|
+
- FTBQuestのみ翻訳化だったが、Modの翻訳も出来るようにしたため、名前が機能にそぐわなくなった
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
10
|
+
and orientation.
|
11
|
+
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
14
|
+
|
15
|
+
## Our Standards
|
16
|
+
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
19
|
+
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
+
and learning from the experience
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
26
|
+
overall community
|
27
|
+
|
28
|
+
Examples of unacceptable behavior include:
|
29
|
+
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or
|
31
|
+
advances of any kind
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33
|
+
* Public or private harassment
|
34
|
+
* Publishing others' private information, such as a physical or email
|
35
|
+
address, without their explicit permission
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
37
|
+
professional setting
|
38
|
+
|
39
|
+
## Enforcement Responsibilities
|
40
|
+
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
+
or harmful.
|
45
|
+
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
+
decisions when appropriate.
|
50
|
+
|
51
|
+
## Scope
|
52
|
+
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
+
an individual is officially representing the community in public spaces.
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
56
|
+
posting via an official social media account, or acting as an appointed
|
57
|
+
representative at an online or offline event.
|
58
|
+
|
59
|
+
## Enforcement
|
60
|
+
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
+
reported to the community leaders responsible for enforcement at
|
63
|
+
.
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
+
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
68
|
+
|
69
|
+
## Enforcement Guidelines
|
70
|
+
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
+
|
74
|
+
### 1. Correction
|
75
|
+
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
78
|
+
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
82
|
+
|
83
|
+
### 2. Warning
|
84
|
+
|
85
|
+
**Community Impact**: A violation through a single incident or series
|
86
|
+
of actions.
|
87
|
+
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or
|
93
|
+
permanent ban.
|
94
|
+
|
95
|
+
### 3. Temporary Ban
|
96
|
+
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
99
|
+
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
105
|
+
|
106
|
+
### 4. Permanent Ban
|
107
|
+
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
+
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
113
|
+
the community.
|
114
|
+
|
115
|
+
## Attribution
|
116
|
+
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.0, available at
|
119
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
120
|
+
|
121
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
122
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
123
|
+
|
124
|
+
[homepage]: https://www.contributor-covenant.org
|
125
|
+
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
127
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
128
|
+
https://www.contributor-covenant.org/translations.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 milkeclair
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
## ModpackLocalizer
|
2
|
+
|
3
|
+
Translator for FTBQuest. (title, subtitle, description)
|
4
|
+
If you want to translate to other languages than Japanese,
|
5
|
+
please add the `language` option during initialization.
|
6
|
+
Can always get help with `ModpackLocalizer.help`
|
7
|
+
|
8
|
+
#### Example
|
9
|
+
|
10
|
+
`ModpackLocalizer::SNBT::Performer.new(language: "English")`
|
11
|
+
or if no specific configs required
|
12
|
+
`ModpackLocalizer.omakase(language: "English")`
|
13
|
+
|
14
|
+
## Steps
|
15
|
+
|
16
|
+
1. Download [release](https://github.com/milkeclair/modpack_localizer/releases)
|
17
|
+
2. Make `.env` file
|
18
|
+
3. Add `OPENAI_API_KEY=your_api_key` to `.env`
|
19
|
+
4. Optional: Add `OPENAI_MODEL=some_openai_model` to `.env` **(default: gpt-4o-mini)**
|
20
|
+
5. Add `some.snbt` or `quests` directory contents to `quests` directory
|
21
|
+
6. Check `output` directory
|
22
|
+
|
23
|
+
## ModpackLocalizer.omakase Options
|
24
|
+
|
25
|
+
#### language
|
26
|
+
|
27
|
+
Which language do you want to translate to?
|
28
|
+
**(default: Japanese)**
|
29
|
+
|
30
|
+
#### country
|
31
|
+
|
32
|
+
Your country name
|
33
|
+
**(default: Japan)**
|
34
|
+
|
35
|
+
#### locale_code
|
36
|
+
|
37
|
+
Which locale code do you want to use?
|
38
|
+
If you specified this, you don't need to specify the country.
|
39
|
+
**(default: nil)**
|
40
|
+
|
41
|
+
#### threadable
|
42
|
+
|
43
|
+
Do you want to exec in parallel?
|
44
|
+
**(default: false)**
|
45
|
+
|
46
|
+
## Initialize Options
|
47
|
+
|
48
|
+
#### output_logs
|
49
|
+
|
50
|
+
Want to output OpenAI usage logs?
|
51
|
+
**(default: true)**
|
52
|
+
|
53
|
+
#### except_words
|
54
|
+
|
55
|
+
Words that you don't want to translate
|
56
|
+
**(default: empty array)**
|
57
|
+
|
58
|
+
#### language
|
59
|
+
|
60
|
+
Which language do you want to translate to?
|
61
|
+
**(default: Japanese)**
|
62
|
+
|
63
|
+
#### display_help
|
64
|
+
|
65
|
+
Want to display help?
|
66
|
+
**(default: true)**
|
67
|
+
|
68
|
+
## Only for jar performer
|
69
|
+
|
70
|
+
#### country
|
71
|
+
|
72
|
+
Your country name
|
73
|
+
**(default: Japan)**
|
74
|
+
|
75
|
+
#### locale_code
|
76
|
+
|
77
|
+
Which locale code do you want to use?
|
78
|
+
If you specified this, you don't need to specify the country.
|
79
|
+
**(default: nil)**
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "rubocop/rake_task"
|
6
|
+
require "yard"
|
7
|
+
require_relative "rake_helper"
|
8
|
+
|
9
|
+
desc "analysis"
|
10
|
+
task :analysis do
|
11
|
+
sh "bundle install"
|
12
|
+
|
13
|
+
RakeHelper.init_rake_tasks
|
14
|
+
|
15
|
+
puts "--- rspec ---"
|
16
|
+
Rake::Task[:spec].invoke
|
17
|
+
|
18
|
+
puts "--- rubocop ---"
|
19
|
+
Rake::Task[:rubocop].invoke
|
20
|
+
|
21
|
+
puts "--- yard ---"
|
22
|
+
Rake::Task[:yard].invoke
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "push to github packages and rubygems"
|
26
|
+
task :push do
|
27
|
+
sh "bundle install"
|
28
|
+
|
29
|
+
puts "--- build ---"
|
30
|
+
RakeHelper.build_gem
|
31
|
+
|
32
|
+
puts "--- push to github packages ---"
|
33
|
+
RakeHelper.push_to_github_packages
|
34
|
+
|
35
|
+
puts "--- push to rubygems ---"
|
36
|
+
RakeHelper.push_to_rubygems
|
37
|
+
end
|
38
|
+
|
39
|
+
task default: :analysis
|
data/dist/Gemfile
ADDED
data/dist/example.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative "../lib/modpack_localizer"
|
2
|
+
|
3
|
+
file_path = "dist/mods"
|
4
|
+
language = "japanese"
|
5
|
+
country_name = "japan"
|
6
|
+
|
7
|
+
performer = ModpackLocalizer::JAR::Performer.new(language: language, country: country_name, display_help: false)
|
8
|
+
performer.perform_directory(dir_path: file_path)
|
9
|
+
|
10
|
+
#ModpackLocalizer.omakase(language: "Japanese", country: "Japan", locale_code: nil, threadable: true)
|
data/dist/start.bat
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
require "jp_translator_from_gpt"
|
2
|
+
require "active_support/core_ext/string/inflections"
|
3
|
+
require_relative "../util/help"
|
4
|
+
require_relative "../util/error"
|
5
|
+
require_relative "reader"
|
6
|
+
require_relative "writer"
|
7
|
+
|
8
|
+
module ModpackLocalizer
|
9
|
+
module JAR
|
10
|
+
# .jarの翻訳を実行するクラス
|
11
|
+
# JpTranslatorFromGptを使用して翻訳を行う
|
12
|
+
class Performer
|
13
|
+
# locale_codeを指定する場合、countryの指定は不要
|
14
|
+
#
|
15
|
+
# @param [Boolean] output_logs APIのログを出力するか
|
16
|
+
# @param [Array<String>] except_words 翻訳しない単語
|
17
|
+
# @param [String] language 言語
|
18
|
+
# @param [String] country 国
|
19
|
+
# @param [String] locale_code ロケールコード (例: "ja_jp")
|
20
|
+
# @param [Boolean] display_help ヘルプを表示するか
|
21
|
+
# @return [ModpackLocalizer::JAR::Performer]
|
22
|
+
def initialize(
|
23
|
+
output_logs: true, except_words: [], language: "Japanese",
|
24
|
+
country: "Japan", locale_code: nil, display_help: true
|
25
|
+
)
|
26
|
+
@translator = JpTranslatorFromGpt::Translator.new(
|
27
|
+
output_logs: output_logs,
|
28
|
+
except_words: except_words,
|
29
|
+
exchange_language: language
|
30
|
+
)
|
31
|
+
@language, @country_name, @locale_code = language, country, locale_code
|
32
|
+
@reader, @writer, @progress_bar, @loggable, @tierdown = nil
|
33
|
+
|
34
|
+
ModpackLocalizer.help if display_help
|
35
|
+
end
|
36
|
+
|
37
|
+
# .jarファイルを翻訳してリソースパックを作成する
|
38
|
+
#
|
39
|
+
# @param [String] file_path ファイルのパス
|
40
|
+
# @param [Boolean] loggable 翻訳ログを出力するか
|
41
|
+
# @param [Boolean] tierdown リソースパック作成後に不要なファイルを削除するか
|
42
|
+
# @return [void]
|
43
|
+
def perform(file_path, loggable: true, tierdown: true)
|
44
|
+
@loggable, @tierdown = loggable, tierdown
|
45
|
+
file_path = File.expand_path(file_path)
|
46
|
+
validate_path(file_path)
|
47
|
+
|
48
|
+
init_reader_and_writer(file_path)
|
49
|
+
lang_data = @reader.extract_lang_json_and_meta_data
|
50
|
+
init_progress_bar(file_path, lang_data.json.length) if @loggable
|
51
|
+
|
52
|
+
need_translation?(lang_data) ? translate(lang_data) : feedback_unnecessary_translation(lang_data)
|
53
|
+
end
|
54
|
+
|
55
|
+
# ディレクトリ内の.jarファイルを翻訳してリソースパックを作成する
|
56
|
+
#
|
57
|
+
# @param [String] dir_path ディレクトリのパス
|
58
|
+
# @param [Boolean] loggable 翻訳ログを出力するか
|
59
|
+
# @return [void]
|
60
|
+
def perform_directory(dir_path: "mods", loggable: true)
|
61
|
+
puts "Performing directory: #{dir_path}" unless loggable
|
62
|
+
dir_path = File.expand_path(dir_path)
|
63
|
+
validate_path(dir_path)
|
64
|
+
|
65
|
+
jar_files = Dir.glob("#{dir_path}/*.jar")
|
66
|
+
if jar_files.empty?
|
67
|
+
puts "JAR files not found in: #{dir_path}"
|
68
|
+
return
|
69
|
+
end
|
70
|
+
|
71
|
+
jar_files.each { |file_path| perform(file_path, loggable: loggable, tierdown: false) }
|
72
|
+
@writer.remove_before_zipping_directory
|
73
|
+
end
|
74
|
+
|
75
|
+
# ファイルの存在性のバリデーション
|
76
|
+
#
|
77
|
+
# @param [String] path ファイルのパス
|
78
|
+
# @return [void]
|
79
|
+
def validate_path(path)
|
80
|
+
path = File.expand_path(path)
|
81
|
+
raise ModpackLocalizer::PathNotFoundError.new(path) unless File.exist?(path)
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
# ReaderとWriterを初期化する
|
87
|
+
#
|
88
|
+
# @params [String] file_path ファイルのパス
|
89
|
+
# @return [void]
|
90
|
+
def init_reader_and_writer(file_path)
|
91
|
+
@reader = ModpackLocalizer::JAR::Reader.new(file_path, @language, @country_name, @locale_code)
|
92
|
+
@writer = ModpackLocalizer::JAR::Writer.new
|
93
|
+
end
|
94
|
+
|
95
|
+
# プログレスバーを初期化する
|
96
|
+
#
|
97
|
+
# @param [String] file_path ファイルのパス
|
98
|
+
# @param [Integer] length プログレスバーの長さ
|
99
|
+
# @return [void]
|
100
|
+
def init_progress_bar(file_path, length)
|
101
|
+
@progress_bar = ModpackLocalizer.create_progress_bar(file_path, length)
|
102
|
+
end
|
103
|
+
|
104
|
+
# 翻訳が必要か判定する
|
105
|
+
#
|
106
|
+
# @param [LangData] lang_data Readerから取得したデータ
|
107
|
+
# @return [Boolean]
|
108
|
+
def need_translation?(lang_data)
|
109
|
+
lang_data.need_translation
|
110
|
+
end
|
111
|
+
|
112
|
+
# 翻訳を実行する
|
113
|
+
#
|
114
|
+
# @param [LangData] lang_data Readerから取得したデータ
|
115
|
+
# @return [void]
|
116
|
+
def translate(lang_data)
|
117
|
+
lang_data.json.each do |key, value|
|
118
|
+
lang_data.json[key] = @translator.translate(value)
|
119
|
+
@progress_bar.increment if @loggable
|
120
|
+
end
|
121
|
+
|
122
|
+
@writer.make_resource_pack(lang_data)
|
123
|
+
@writer.remove_before_zipping_directory if @tierdown
|
124
|
+
puts "Mod translation completed!"
|
125
|
+
end
|
126
|
+
|
127
|
+
# 翻訳が不要な場合のフィードバックを出力する
|
128
|
+
#
|
129
|
+
# @param [LangData] lang_data Readerから取得したデータ
|
130
|
+
# @return [void]
|
131
|
+
def feedback_unnecessary_translation(lang_data)
|
132
|
+
return unless @loggable
|
133
|
+
|
134
|
+
@progress_bar.finish
|
135
|
+
puts already_has_translated_file_message(lang_data)
|
136
|
+
end
|
137
|
+
|
138
|
+
# 既に翻訳済みのファイルが存在する旨のメッセージを出力する
|
139
|
+
#
|
140
|
+
# @param [LangData] lang_data Readerから取得したデータ
|
141
|
+
# @return [String]
|
142
|
+
def already_has_translated_file_message(lang_data)
|
143
|
+
"#{lang_data.mod_name.camelize} already has #{@reader.extract_file_name(lang_data.file_name)} file."
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|