Module: ModpackLocalizer

Defined in:
lib/modpack_localizer.rb,
lib/modpack_localizer/util/help.rb,
lib/modpack_localizer/jar/reader.rb,
lib/modpack_localizer/jar/writer.rb,
lib/modpack_localizer/util/error.rb,
lib/modpack_localizer/snbt/reader.rb,
lib/modpack_localizer/snbt/writer.rb,
lib/modpack_localizer/util/version.rb,
lib/modpack_localizer/jar/performer.rb,
lib/modpack_localizer/snbt/formatter.rb,
lib/modpack_localizer/snbt/performer.rb,
lib/modpack_localizer/util/indent_helper.rb,
lib/modpack_localizer/snbt/title_extractor.rb,
lib/modpack_localizer/snbt/subtitle_extractor.rb,
lib/modpack_localizer/snbt/description_extractor.rb

Overview

SNBT形式のファイルを翻訳する 翻訳できるプロパティ

  • title

  • subtitle

  • description

Defined Under Namespace

Modules: IndentHelper, JAR, SNBT Classes: Error, Help, InvalidLineCountError, InvalidRegionCodeError, PathNotFoundError

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.create_progress_bar(file_path, total) ⇒ ProgressBar::Base

プログレスバーを生成する

Parameters:

  • file_path (String)

    ファイルのパス

  • total (Integer)

    プログレスバーの合計数

Returns:

  • (ProgressBar::Base)

    プログレスバー



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/modpack_localizer.rb', line 49

def self.create_progress_bar(file_path, total)
  # パスの内、カレントディレクトリ配下のパス以外は邪魔なので削除
  # 例: /Users/user/quests/some.snbt -> /quests/some.snbt
  puts "\nFile path: #{file_path.gsub(Dir.pwd, "")}"

  ProgressBar.create(
    title: "Translating...",
    total: total,
    progress_mark: "#",
    format: "%t [%B]",
    length: 80,
    projector: {
      type: "smoothed",
      strength: 0.1
    }
  )
end

.helpvoid

This method returns an undefined value.

ModpackLocalizer gemについてのヘルプを表示する



40
41
42
# File 'lib/modpack_localizer.rb', line 40

def self.help
  ModpackLocalizer::Help.help
end

.omakase(language: "Japanese", country: "Japan", locale_code: nil, threadable: false) ⇒ void

This method returns an undefined value.

quests, mods配下のファイルを全て翻訳する locale_codeを指定する場合、countryの指定は不要

Parameters:

  • language (String) (defaults to: "Japanese")

    言語

  • country (String) (defaults to: "Japan")

  • locale_code (String) (defaults to: nil)

    ロケールコード(例: “ja_jp”)

  • threadable (Boolean) (defaults to: false)

    quests, modsの翻訳を並列で行うか



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/modpack_localizer.rb', line 23

def self.omakase(language: "Japanese", country: "Japan", locale_code: nil, threadable: false)
  performers = [] << ModpackLocalizer::SNBT::Performer.new(language: language)
  performers << ModpackLocalizer::JAR::Performer.new(
    language: language, country: country, locale_code: locale_code, display_help: false
  )

  if threadable
    threads = performers.map { |pfm| Thread.new { pfm.perform_directory(loggable: false) } }
    threads.each(&:join)
  else
    performers.each(&:perform_directory)
  end
end