Без опису

Bepis 13795de5bd Initial code commit 7 роки тому
libs 13795de5bd Initial code commit 7 роки тому
src 13795de5bd Initial code commit 7 роки тому
.gitattributes 13795de5bd Initial code commit 7 роки тому
.gitignore 13795de5bd Initial code commit 7 роки тому
CHANGELOG.md 13795de5bd Initial code commit 7 роки тому
LICENSE fa223cac8f Initial commit 7 роки тому
README.md 13795de5bd Initial code commit 7 роки тому
XUnity.AutoTranslator.sln 13795de5bd Initial code commit 7 роки тому

README.md

XUnity Auto Translator

Text Frameworks

This is an auto translation mod that hooks into the unity game engine and attempts to provide translations for the following text frameworks for Unity:

  • UGUI
  • IMGUI
  • NGUI
  • TextMeshPro

It does go to the internet, in order to provide the translation, so if you are not comfortable with that, dont use it.

Plugin Frameworks

The mod can be installed into the following Plugin Managers:

Installations instructions for both methods can be found below.

Configuration

The default configuration file, looks as such:

[AutoTranslator]
Endpoint=GoogleTranslate                                          ;the endpoint to use to translate
Language=en                                                       ;the language to translate into
FromLanguage=ja                                                   ;the language to translate fromm
Delay=0                                                           ;a delay to be applied before attempting to translate a text, if the text framework supports it. Measured in seconds
Directory=Translation                                             ;the directory that the plugin will look for cached translations in
OutputFile=Translation\_AutoGeneratedTranslations.{lang}.txt      ;the file that the plugin will write auto translated texts to
MaxCharactersPerTranslation=150                                   ;the max number of characters that a text may contain in order to be translated
EnableIMGUI=True                                                  ;specify if IMGUI should be translated
EnableUGUI=True                                                   ;specify if UGUI should be translated
EnableNGUI=True                                                   ;specify if NGUI should be translated
EnableTextMeshPro=True                                            ;specify if TextMeshPro should be translated
AllowPluginHookOverride=True                                      ;specify whether to allow other plugins to override this plugins code hooks

Key Mapping

The following key inputs are mapped:

  • ALT + T: Alternate between translated and untranslated versions of all texts provided by this plugin.
  • ALT + D: Dump untranslated texts (if no endpoint is configured)
  • ALT + R: Reload translation files. Useful if you change the text files on the fly.

Installation

The plugin can be installed in following ways:

BepInEx Plugin

REQUIRES: BepInEx plugin manager (follow its installation instructions first!).

  1. Download XUnity.AutoTranslator-BepIn-{VERSION}.zip from releases.
  2. Extract directly into the game directory, such that the plugin dlls are placed in BepInEx folder.

The file structure should likke like this:

{GameDirectory}/BepInEx/XUnity.AutoTranslator.Plugin.Core.dll
{GameDirectory}/BepInEx/XUnity.AutoTranslator.Plugin.Core.BepInEx.dll
{GameDirectory}/BepInEx/ExIni.dll
{GameDirectory}/BepInEx/Translation/AnyTranslationFile.txt (this files will be auto generated by plugin!)

IPA Plugin

REQUIRES: IPA plugin manager (follow its installation instructions first!).

  1. Download XUnity.AutoTranslator-IPA-{VERSION}.zip from releases.
  2. Extract directly into the game directory, such that the plugin dlls are placed in Plugins folder.

The file structure should likke like this

{GameDirectory}/Plugins/XUnity.AutoTranslator.Plugin.Core.dll
{GameDirectory}/Plugins/XUnity.AutoTranslator.Plugin.Core.IPA.dll
{GameDirectory}/Plugins/0Harmony.dll
{GameDirectory}/Plugins/ExIni.dll
{GameDirectory}/Plugins/Translation/AnyTranslationFile.txt (this files will be auto generated by plugin!)

Integrating with Auto Translator

I have implemented a system that allows other dedicated translation mods to integrate with XUnity AutoTranslator.

Basically, as a mod author, you are able to, if you cannot find a translation to a string, simply delegate it to this mod, and you can do it without taking any references to this plugin.

Here's how it works, and what is required:

  • You must implement a Component (MonoBehaviour for instance) that this plugin is able to locate by simply traversing all objects during startup.
  • On this component you must add an event for the text hooks you want to override from XUnity AutoTranslator. This is done on a per text framework basis. The signature of these events must be: Func. The arguments are, in order:
    1. The component that represents the text in the UI. (The one that probably has a property called 'text').
    2. The untranslated text
    3. This is the return value and will be the translated text IF an immediate translation took place. Otherwise it will simply be null.
  • The signature for each framework looks like:
    1. UGUI: public static event Func OnUnableToTranslateUGUI
    2. TextMeshPro: public static event Func OnUnableToTranslateTextMeshPro
    3. NGUI: public static event Func OnUnableToTranslateNGUI
    4. Also, the events can be either instance based or static.