Coder Social home page Coder Social logo

xunity.autotranslator's Introduction

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
  • NGUI
  • TextMeshPro
  • IMGUI

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 (2.4.0+):

[Service]
Endpoint=GoogleTranslate         ;Endpoint to use. Can be ["GoogleTranslate", "BaiduTranslate"]
EnableSSL=False                  ;Whether or not to use HTTPS endpoint over standard HTTP

[General]
Language=en                      ;The language to translate into
FromLanguage=ja                  ;The original language of the game

[Files]
Directory=Translation                                          ;Directory to search for cached translation files
OutputFile=Translation\_AutoGeneratedTranslations.{lang}.txt   ;File to insert generated translations into

[TextFrameworks]
EnableUGUI=True                  ;Enable or disable UGUI translation
EnableNGUI=True                  ;Enable or disable NGUI translation
EnableTextMeshPro=True           ;Enable or disable TextMeshProp translation
EnableIMGUI=False                ;Enable of disable IMGUI translation
AllowPluginHookOverride=True     ;Allow other text translation plugins to override this plugin's hooks

[Behaviour]
Delay=0                          ;Delay to wait before attempting to translate a text in seconds
MaxCharactersPerTranslation=150  ;Max characters per text to translate
IgnoreWhitespaceInDialogue=True  ;Whether or not to ignore whitespace, such as newlines, in dialogue keys
MinDialogueChars=20              ;The length of the text for it to be considered a dialogue
ForceSplitTextAfterCharacters=0  ;Split text into multiple lines once the translated text exceeds this number of characters
CopyToClipboard=False            ;Whether or not to copy hooked texts to clipboard
MaxClipboardCopyCharacters=450   ;Max number of characters to hook to clipboard at a time

[Baidu]
BaiduAppId=                      ;OPTIONAL, needed if BaiduTranslate is configured
BaiduAppSecret=                  ;OPTIONAL, needed if BaiduTranslate is configured

[Debug]
EnablePrintHierarchy=False       ;Used for debugging

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<object, string, string>. 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<object, string, string> OnUnableToTranslateUGUI
    2. TextMeshPro: public static event Func<object, string, string> OnUnableToTranslateTextMeshPro
    3. NGUI: public static event Func<object, string, string> OnUnableToTranslateNGUI
  • Also, the events can be either instance based or static.

xunity.autotranslator's People

Contributors

bbepis avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.