Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- ==============================================================================
- ■ Strumento per la localizzazione di Holy87
- versione 1.0.1
- Difficoltà utente: ★
- Licenza: CC. Chiunque può scaricare, modificare, distribuire e utilizzare
- lo script nei propri progetti, sia amatoriali che commerciali. Vietata
- l'attribuzione impropria.
- ==============================================================================
- Questo script localizza automaticamente un gioco già completo, creando un
- file della lingua specifico.
- ==============================================================================
- ■ Compatibilità
- Necessita dello script di localizzazione.
- ==============================================================================
- ■ Changelog
- 07/06/2015 -> v1.0.1
- ● Fix di un errore di conversione
- ● Fix per un problema che cancellava i nomi delle mappe
- ==============================================================================
- ■ Installazione e istruzioni
- ● Installare questo script sotto Materials e prima del Main.
- ● Necessita dello script di localizzazione.
- ● Assicurarsi di aver creato la cartella Localization nel gioco.
- ● FARE UNA COPIA DI BACKUP. Il tool modifica irrimediabilmente TUTTI i
- dialoghi, quindi assicurati di fare una copia del gioco nel caso vada
- storto qualcosa.
- ● Avviare il gioco in modalità TEST, quindi alla schermata del titolo
- tieni premuto la freccia sinistra e premi ESC. Seleziona la lingua in cui
- verrà creato il file di localizzazione (se non c'è metti altro, poi potrai
- configurare l'header manualmente)
- ● Al termine dell'operazione, il file della lingua sarà creato.
- ● IMPORTANTE: Appena finita la conversione, chiuderere RPG Maker SENZA
- salvare (o le modifiche verranno sovrascritte) quindi riaprire RPG Maker.
- ■ Cosa fa lo strumento
- ● Crea un file della lingua nella cartella Localization, con header e
- rispettive informazioni
- ● Scandaglia tutto il database e scrive nel file le informazioni di tutti
- gli eroi, classi, skill, oggetti, armi, armature, nemici e stati
- ● Cerca in tutte le mappe, in tutte le battaglie e in tutti gli eventi comuni
- i messaggi di dialoghi e, quando li trova, crea la stringa con la chiave
- all'interno del file e MODIFICA il dialogo con la chiave della stringa
- creata
- ● Scrive anche i nomi delle mappe
- ■ Cosa NON fa lo strumento
- ● Traduzione. Non fa alcuna traduzione, una volta creata la localizzazione
- dovrai tradurre stringa per stringa il file (o farlo fare ad altri) nelle
- altre lingue.
- ● Creare una localizzazione per le stringhe negli script. Mi spiace, ma
- questa è una cosa che si deve fare manualmente.
- ==============================================================================
- =end
- module LocalizationOptions
- #--------------------------------------------------------------------------
- # * Lingue del menu. È semplicemente una comodità per creare lingue già
- # configurare. Altro crea il file della lingua, ma bisogna modificare
- # l'header manualmente.
- #--------------------------------------------------------------------------
- LANGUAGES = {
- #ID #sigla #nome completo
- 1033 => ["en", "English"], #inglese-stati uniti
- 1040 => ["it", "Italiano"], #italiano tradizionale
- 1036 => ["fr", "Français"], #francese
- 1031 => ["de", "Deutsch"], #tedesco
- 1034 => ["es", "Español"], #spagnolo
- 1030 => ["da", "Danske"], #danese
- 1026 => ["bg-BG" "Belgian"], #belga
- 1027 => ["ca-ES" "Català"], #catalano
- 1041 => ["jp", "日本 - 日本語"], #giapponese
- 1042 => ["ko", "한국의"], #coreano
- 1049 => ["ru", "Pусский"], #russo
- 2055 => ["de-BG", "Deutsch - Schweizer"], #tedesco-svizzero
- 4103 => ["de-LU", "Deutsch - Luxemburg"], #tedesco-lussemburgo
- 2057 => ["en-UL", "English - UK"], #inglese-regno unito
- 3081 => ["en-AU", "English - Australia"], #inglese australiano
- 4105 => ["en-CA", "English - Canada"], #inglese canadese
- 5129 => ["en-NZ", "English - New Zeland"],#inglese nuova zelanda
- 2058 => ["es-MX", "Español - México"], #spagnolo messicano
- 11274 => ["es-AR", "Español - Cile"], #spagnolo-cile
- 2060 => ["fr-BE", "Français - Belgique"], #francese belgio
- 4108 => ["fr-CH", "Français - Suisse"], #francese svizzero
- 2064 => ["it-CH", "Italiano - Svizzera"], #italiano svizzero
- 0 => ["na", "Altro"], #altra lingua da configurare successivamente
- }
- #--------------------------------------------------------------------------
- # * Vocaboli della schermata
- #--------------------------------------------------------------------------
- VOCABS = {
- :start => "Inizia conversione",
- :select=> "Seleziona lingua",
- :exit => "Esci",
- :wait => "Creazione del file %s in corso...",
- :done => "Creazione della lingua completata.",
- }
- #--------------------------------------------------------------------------
- # * Le chiavi delle stringhe che verranno create.
- #--------------------------------------------------------------------------
- STRING = "Map[%03d] Ev[%03d] Page %02d Line %d"
- CHOICE = "Map[%03d] Ev[%03d] Page %02d Line %d - %d"
- BATTLE = "Troop[%03d] Page %02d Line %d"
- BATTLC = "Troop[%03d] Page %02d Line %d - %d"
- COMMON = "C. Ev[%03d] Line %d"
- COMMOC = "C. Ev[%03d] Line %d - %d"
- MAPNAM = "Map[%03d] Name"
- #--------------------------- FINE DELLO SCRIPT ------------------------------
- #--------------------------------------------------------------------------
- # * Returns the proper vocab
- #--------------------------------------------------------------------------
- def vocab(vocab_id)
- return VOCABS[vocab_id]
- end
- end
- #==============================================================================
- # ** Scene_Localization
- #------------------------------------------------------------------------------
- # Scene for localization tool
- #==============================================================================
- class Scene_Localization < Scene_MenuBase
- include LocalizationOptions
- #--------------------------------------------------------------------------
- # * start
- #--------------------------------------------------------------------------
- def start
- super
- create_localization_window
- create_language_window
- create_popup_window
- end
- #--------------------------------------------------------------------------
- # * localization window creation
- #--------------------------------------------------------------------------
- def create_localization_window
- @localization_window = Window_LocalizationInfo.new
- @localization_window.set_handler(:start, method(:open_language))
- @localization_window.set_handler(:cancel, method(:return_scene))
- @localization_window.activate
- end
- #--------------------------------------------------------------------------
- # * language list windows creation
- #--------------------------------------------------------------------------
- def create_language_window
- x = @localization_window.x
- @language_window = Window_LanguageList.new(x, 0, 250, Graphics.height)
- @language_window.set_handler(:ok, method(:start_creation))
- @language_window.set_handler(:cancel, method(:open_localization))
- end
- #--------------------------------------------------------------------------
- # * popup window creation
- #--------------------------------------------------------------------------
- def create_popup_window
- @popup_window = Window_ToolPpup.new
- @popup_window.set_pressure_method(method(:process_done))
- end
- #--------------------------------------------------------------------------
- # * start creation
- #--------------------------------------------------------------------------
- def start_creation
- @language_window.openness = 0
- @popup_window.visible = true
- @popup_window.set_text(vocab(:wait))
- Graphics.update
- localization_tool = Loc_Tool.new(@language_window.item)
- localization_tool.start_creating
- @popup_window.activate
- @popup_window.set_text(sprintf(vocab(:done), localization_tool.file_name))
- end
- #--------------------------------------------------------------------------
- # * language selection process
- #--------------------------------------------------------------------------
- def open_language
- @localization_window.close
- @language_window.open
- @language_window.activate
- end
- #--------------------------------------------------------------------------
- # * localization process (back)
- #--------------------------------------------------------------------------
- def open_localization
- @language_window.close
- @localization_window.open
- @localization_window.activate
- end
- #--------------------------------------------------------------------------
- # * localization done
- #--------------------------------------------------------------------------
- def process_done
- @popup_window.visible = false
- @popup_window.deactivate
- @localization_window.open
- @localization_window.activate
- end
- end
- #==============================================================================
- # ** Window_LocalizationInfo
- #------------------------------------------------------------------------------
- # window for localization commands
- #==============================================================================
- class Window_LocalizationInfo < Window_Command
- include LocalizationOptions
- #--------------------------------------------------------------------------
- # * initialize
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0)
- update_placement
- self.openness = 0
- open
- end
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- return 250
- end
- #--------------------------------------------------------------------------
- # * Update Window Position
- #--------------------------------------------------------------------------
- def update_placement
- self.x = (Graphics.width - width) / 2
- self.y = (Graphics.height * 1.6 - height) / 2
- end
- #--------------------------------------------------------------------------
- # * Create Command List
- #--------------------------------------------------------------------------
- def make_command_list
- add_command(vocab(:start), :start)
- add_command(vocab(:exit), :cancel)
- end
- end
- #==============================================================================
- # ** Window_LanguageList
- #------------------------------------------------------------------------------
- # Shows the list of avaiable language for this tool
- #==============================================================================
- class Window_LanguageList < Window_Selectable
- include LocalizationOptions
- #--------------------------------------------------------------------------
- # * Object initialization
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super
- make_language_list
- create_contents
- refresh
- self.index = 0
- self.openness = 0
- end
- #--------------------------------------------------------------------------
- # * Make language list
- #--------------------------------------------------------------------------
- def make_language_list
- @data = get_languages(LANGUAGES)
- end
- #--------------------------------------------------------------------------
- # * Get Number of Items
- #--------------------------------------------------------------------------
- def item_max
- @data ? @data.size : 0
- end
- #--------------------------------------------------------------------------
- # * draw_item
- # index: indice dell
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- if item
- rect = item_rect(index)
- rect.width -= 4
- draw_text(rect, item.name)
- end
- end
- #--------------------------------------------------------------------------
- # * Selected item
- #--------------------------------------------------------------------------
- def item
- return @data[@index]
- end
- #--------------------------------------------------------------------------
- # * Get all languages
- #--------------------------------------------------------------------------
- def get_languages(hash)
- ary = []
- hash.each_pair do |a, b|
- ary.push(Language.new(a, b[0], b[1]))
- end
- return ary
- end
- end
- #==============================================================================
- # ** Window_ToolPpup
- #------------------------------------------------------------------------------
- # Window that appears when the localization is finished
- #==============================================================================
- class Window_ToolPpup < Window_Base
- #--------------------------------------------------------------------------
- # * Object initialization
- #--------------------------------------------------------------------------
- def initialize
- super(0,0,0,line_height + standard_padding*2)
- deactivate
- self.visible = false
- end
- #--------------------------------------------------------------------------
- # * Set new text
- # text = new text
- #--------------------------------------------------------------------------
- def set_text(text)
- width = text_size(text).width + self.padding*2
- self.width = width
- x = (Graphics.width - width)/2
- y = (Graphics.height - height)/2
- @text = text
- refresh
- end
- #--------------------------------------------------------------------------
- # * set the method launched when pressing :C
- #--------------------------------------------------------------------------
- def set_pressure_method(mth)
- @method = mth
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- create_contents
- return if @text.nil?
- draw_text(0,0,contents_width, line_height, @text)
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- def update
- super
- check_pressure if self.active == true
- end
- #--------------------------------------------------------------------------
- # * Pressure check
- #--------------------------------------------------------------------------
- def check_pressure
- return unless @method
- @method.call if Input.trigger?(:C) or Input.trigger?(:B)
- end
- end
- #==============================================================================
- # ** Loc_Tool
- #------------------------------------------------------------------------------
- # Localization class that parses all the game and creates the file.
- #==============================================================================
- class Loc_Tool
- include LocalizationOptions
- #--------------------------------------------------------------------------
- # * Object initialization
- # language: language object
- #--------------------------------------------------------------------------
- def initialize(language)
- @id = language.id
- @short = language.short
- @name = language.name
- end
- #--------------------------------------------------------------------------
- # * Returns the language file name
- #--------------------------------------------------------------------------
- def file_name
- H87Localization.language_folder+"/#{@short}.ini"
- end
- #--------------------------------------------------------------------------
- # * Creation process
- #--------------------------------------------------------------------------
- def start_creating
- File.open(file_name,"w") do |file|
- file.write(header)
- file.write(actors)
- file.write(classes)
- file.write(skills)
- file.write(items)
- file.write(weapons)
- file.write(armors)
- file.write(enemies)
- file.write(states)
- file.write(terms)
- file.write(dialogs)
- end
- end
- #--------------------------------------------------------------------------
- # * Header creation
- #--------------------------------------------------------------------------
- def header
- mp = Mark_Parser.new("header")
- mp.add_item("Language",@name)
- mp.add_item("ID",@id)
- return mp.to_s
- end
- #--------------------------------------------------------------------------
- # * Actors list creation
- #--------------------------------------------------------------------------
- def actors
- attributes = [:id, :name, :nickname, :description]
- return attr_process("actors",$data_actors,attributes)
- end
- #--------------------------------------------------------------------------
- # * Classes list creation
- #--------------------------------------------------------------------------
- def classes
- attributes = [:id, :name]
- return attr_process("classes",$data_classes,attributes)
- end
- #--------------------------------------------------------------------------
- # * Skills list creation
- #--------------------------------------------------------------------------
- def skills
- attributes = [:id, :name, :description, :message1, :message2]
- return attr_process("skills",$data_skills,attributes)
- end
- #--------------------------------------------------------------------------
- # * Items list creation
- #--------------------------------------------------------------------------
- def items
- attributes = [:id, :name, :description]
- return attr_process("items",$data_items,attributes)
- end
- #--------------------------------------------------------------------------
- # * Weapons list creation
- #--------------------------------------------------------------------------
- def weapons
- attributes = [:id, :name, :description]
- return attr_process("weapons",$data_weapons,attributes)
- end
- #--------------------------------------------------------------------------
- # * Armors list creation
- #--------------------------------------------------------------------------
- def armors
- attributes = [:id, :name, :description]
- return attr_process("armors",$data_armors,attributes)
- end
- #--------------------------------------------------------------------------
- # * Enemies list creation
- #--------------------------------------------------------------------------
- def enemies
- attributes = [:id, :name]
- return attr_process("enemies",$data_enemies,attributes)
- end
- #--------------------------------------------------------------------------
- # * States list creation
- #--------------------------------------------------------------------------
- def states
- attributes = [:id, :name, :message1, :message2, :message3, :message4]
- return attr_process("states",$data_states,attributes)
- end
- #--------------------------------------------------------------------------
- # * Terms list creation
- #--------------------------------------------------------------------------
- def terms
- terms = $data_system.terms
- mp = Mark_Parser.new("params")
- for i in 0..terms.basic.size-1
- mp.add_item(i, terms.params[i])
- end
- mp2 = Mark_Parser.new("basic")
- for i in 0..terms.basic.size-1
- mp2.add_item(i, terms.basic[i])
- end
- mp3 = Mark_Parser.new("etypes")
- for i in 0..terms.etypes.size-1
- mp3.add_item(i, terms.etypes[i])
- end
- mp4 = Mark_Parser.new("commands")
- for i in 0..terms.commands.size-1
- mp4.add_item(i, terms.commands[i])
- end
- return mp.to_s + mp2.to_s + mp3.to_s + mp4.to_s
- end
- #--------------------------------------------------------------------------
- # * Dialog list creation
- #--------------------------------------------------------------------------
- def dialogs
- mp = Mark_Parser.new("strings")
- records = 0
- records += get_from_map(mp)
- records += get_from_troops(mp)
- records += get_from_common_events(mp)
- println "#{records} strings created from Message Dialogs."
- return mp.to_s
- end
- #--------------------------------------------------------------------------
- # * Get all message box on all over the maps
- #--------------------------------------------------------------------------
- def get_from_map(mp)
- records = 0
- for i in 1..999
- map_file = sprintf("Data/Map%03d.rvdata2", i)
- next unless File.exist?(map_file)
- map = load_data(map_file)
- if !map.display_name.empty?
- name = sprintf(MAPNAM,i)
- mp.add_item(name, map.display_name)
- map.display_name = "{S: #{name}}"
- end
- map.events.each_pair do |event_id, event|
- event.pages.each_with_index do |page, page_i|
- page.list.each_with_index do |command, command_i|
- case command.code
- when 401
- next if command.parameters[0] =~ H87Localization::REG_EXCAPE
- name = sprintf(STRING,i,event_id,page_i,command_i)
- mp.add_item(name, command.parameters[0])
- command.parameters[0] = "{S: #{name}}"
- records += 1
- when 102
- command.parameters[0].each_with_index do |param, param_i|
- next if param =~ H87Localization::REG_EXCAPE
- name = sprintf(CHOICE,i,event_id,page_i,command_i,param_i)
- mp.add_item(name, param)
- command.parameters[0][param_i] = "{S: #{name}}"
- records += 1
- end
- end
- end
- end
- end
- save_data(map, map_file)
- end
- return records
- end
- #--------------------------------------------------------------------------
- # * Get all message box in all troops
- #--------------------------------------------------------------------------
- def get_from_troops(mp)
- records = 0
- for troop in $data_troops
- next if troop.nil?
- troop.pages.each_with_index do |page, page_i|
- page.list.each_with_index do |command, command_i|
- case command.code
- when 401
- next if command.parameters[0] =~ H87Localization::REG_EXCAPE
- name = sprintf(BATTLE,troop.id,page_i,command_i)
- mp.add_item(name, command.parameters[0])
- command.parameters[0] = "{S: #{name}}"
- records += 1
- when 102
- command.parameters[0].each_with_index do |param, param_i|
- next if param =~ H87Localization::REG_EXCAPE
- name = sprintf(BATTLC,troop.id,page_i,command_i,param_i)
- mp.add_item(name, param)
- command.parameters[0][param_i] = "{S: #{name}}"
- records += 1
- end
- end
- end
- end
- end
- save_data($data_troops,"Data/Troops.rvdata2")
- return records
- end
- #--------------------------------------------------------------------------
- # * Gets all message box in all common events
- #--------------------------------------------------------------------------
- def get_from_common_events(mp)
- records = 0
- for event in $data_common_events
- next if event.nil?
- event.list.each_with_index do |command, command_i|
- case command.code
- when 401
- next if command.parameters[0] =~ H87Localization::REG_EXCAPE
- name = sprintf(COMMON,event.id,command_i)
- mp.add_item(name, command.parameters[0])
- command.parameters[0] = "{S: #{name}}"
- records += 1
- when 102
- command.parameters[0].each_with_index do |param, param_i|
- next if param =~ H87Localization::REG_EXCAPE
- name = sprintf(COMMOC,event.id,command_i,param_i)
- mp.add_item(name, param)
- command.parameters[0][param_i] = "{S: #{name}}"
- records += 1
- end
- end
- end
- end
- save_data($data_common_events, "Data/CommonEvents.rvdata2")
- return records
- end
- #--------------------------------------------------------------------------
- # * Process that creates tag with attributes
- # name: tag name
- # array: database array
- # attributes: attributes to copy
- #--------------------------------------------------------------------------
- def attr_process(name, array, attributes)
- mp = Mark_Parser.new(name)
- for item in array
- next if item.nil?
- next if item.name.empty?
- next if item.name == " "
- mp.add_item
- for attr in attributes
- attr_value = eval("item.#{attr}")
- next if attr_value == ""
- mp.push_attr(attr.to_s, attr_value)
- end
- end
- println "#{name} saved. #{array.size} lines created."
- return mp.to_s
- end
- end
- #==============================================================================
- # ** Mark Parser
- #------------------------------------------------------------------------------
- # This class is used within Localization_Tool and creates the string that
- # will be written into the file.
- #==============================================================================
- class Mark_Parser
- attr_accessor :tag
- #--------------------------------------------------------------------------
- # * Object initialization
- #--------------------------------------------------------------------------
- def initialize(tag)
- @tag = tag
- @items = []
- end
- #--------------------------------------------------------------------------
- # * Add attribute to item
- # attr_name: name of attribute
- # value: value of attribute
- #--------------------------------------------------------------------------
- def push_attr(attr_name, value)
- return if value =~ H87Localization::REG_EXCAPE
- val = value.to_s.gsub(/[\r\n]+/,"\\n").gsub(";","\\;")
- @items.last.push("#{attr_name}:#{val}")
- end
- #--------------------------------------------------------------------------
- # * Add new item
- #--------------------------------------------------------------------------
- def add_item(attr_name = nil, value = nil)
- @items.push([])
- push_attr(attr_name, value) if attr_name != nil
- end
- #--------------------------------------------------------------------------
- # * String converter
- #--------------------------------------------------------------------------
- def to_s
- string = ""
- string << "<#{@tag}>\n"
- @items.each do |item|
- string << item * "; "
- string << "\n"
- end
- string << "</#{@tag}>\n\n"
- return string
- end
- end
- #==============================================================================
- # ** Scene_Title
- #------------------------------------------------------------------------------
- # Access for tool's scene
- #==============================================================================
- class Scene_Title < Scene_Base
- alias h87loctool_update update unless $@
- #--------------------------------------------------------------------------
- # * update
- #--------------------------------------------------------------------------
- def update
- h87loctool_update
- go_loc_tool if Input.trigger?(:B) && Input.press?(:LEFT) && $TEST
- end
- #--------------------------------------------------------------------------
- # * go to localizer tool scene
- #--------------------------------------------------------------------------
- def go_loc_tool
- SceneManager.call(Scene_Localization)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement