|
6 年 前 | |
---|---|---|
libs | 6 年 前 | |
src | 6 年 前 | |
.editorconfig | 6 年 前 | |
.gitattributes | 7 年 前 | |
.gitignore | 7 年 前 | |
CHANGELOG.md | 6 年 前 | |
LICENSE | 7 年 前 | |
README.md | 6 年 前 | |
XUnity.AutoTranslator.sln | 6 年 前 |
# XUnity Auto Translator
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:
It does go to the internet, in order to provide the translation, so if you are not comfortable with that, dont use it.
The mod can be installed into the following Plugin Managers:
Installations instructions for both methods can be found below.
Additionally it can be installed without a dependency on a plugin manager through ReiPatcher. However, this approach is not recommended if you use one of the above mentioned Plugin Managers!
The default configuration file, looks as such (2.6.0+):
[Service]
Endpoint=GoogleTranslate ;Endpoint to use. Can be ["GoogleTranslate", "GoogleTranslateLegitimate", "BaiduTranslate", "YandexTranslate", "WatsonTranslate", "ExciteTranslate", ""]. If empty, it simply means: Only use cached translations
[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, including newlines, in dialogue keys
IgnoreWhitespaceInNGUI=True ;Whether or not to ignore whitespace, including newlines, in NGUI
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
EnableUIResizing=True ;Whether or not the plugin should provide a "best attempt" at resizing UI components upon translation. Only work for NGUI
EnableBatching=True ;Indicates whether batching of translations should be enabled for supported endpoints
TrimAllText=True ;Indicates whether spaces in front and behind translation candidates should be removed before translation
UseStaticTranslations=True ;Indicates whether or not to use translations from the included static translation cache
OverrideFont= ;Overrides the fonts used for texts when updating text components. NOTE: Only works for UGUI
WhitespaceRemovalStrategy=TrimPerNewline ;Indicates how whitespace/newline removal should be handled before attempting translation. Can be ["TrimPerNewline", "AllOccurrences"]
[Http]
UserAgent= ;Override the user agent used by APIs requiring a user agent
[GoogleLegitimate]
GoogleAPIKey= ;OPTIONAL, needed if GoogleTranslateLegitimate is configured
[Baidu]
BaiduAppId= ;OPTIONAL, needed if BaiduTranslate is configured
BaiduAppSecret= ;OPTIONAL, needed if BaiduTranslate is configured
[Yandex]
YandexAPIKey= ;OPTIONAL, needed if YandexTranslate is configured
[Watson]
WatsonAPIUrl= ;OPTIONAL, needed if WatsonTranslate is configured
WatsonAPIUsername= ;OPTIONAL, needed if WatsonTranslate is configured
WatsonAPIPassword= ;OPTIONAL, needed if WatsonTranslate is configured
[Debug]
EnablePrintHierarchy=False ;Used for debugging
EnableConsole=False ;Enables the console. Do not enable if other plugins (managers) handles this
EnableLog=False ;Enables extra logging for debugging purposes
[Migrations]
Enable=True ;Used to enable automatic migrations of this configuration file
Tag=2.9.0 ;Tag representing the last version this plugin was executed under. Do not edit
The following key inputs are mapped:
The plugin can be installed in following ways:
REQUIRES: BepInEx plugin manager (follow its installation instructions first!).
The file structure should like 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 (these files will be auto generated by plugin!)
REQUIRES: IPA plugin manager (follow its installation instructions first!).
The file structure should like 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 (these files will be auto generated by plugin!)
REQUIRES: UnityInjector (follow its installation instructions first!).
The file structure should like like this
{GameDirectory}/UnityInjector/XUnity.AutoTranslator.Plugin.Core.dll
{GameDirectory}/UnityInjector/XUnity.AutoTranslator.Plugin.Core.UnityInjector.dll
{GameDirectory}/UnityInjector/0Harmony.dll
{GameDirectory}/UnityInjector/ExIni.dll
{GameDirectory}/UnityInjector/Translation/AnyTranslationFile.txt (these files will be auto generated by plugin!)
REQUIRES: Nothing, ReiPatcher is provided by this download.
The file structure should like like this
{GameDirectory}/ReiPatcher/Patches/XUnity.AutoTranslator.Patcher.dll
{GameDirectory}/ReiPatcher/ExIni.dll
{GameDirectory}/ReiPatcher/Mono.Cecil.dll
{GameDirectory}/ReiPatcher/Mono.Cecil.Inject.dll
{GameDirectory}/ReiPatcher/Mono.Cecil.Mdb.dll
{GameDirectory}/ReiPatcher/Mono.Cecil.Pdb.dll
{GameDirectory}/ReiPatcher/Mono.Cecil.Rocks.dll
{GameDirectory}/ReiPatcher/ReiPatcher.exe
{GameDirectory}/{GameExeName}_Data/Managed/ReiPatcher.exe
{GameDirectory}/{GameExeName}_Data/Managed/XUnity.AutoTranslator.Plugin.Core.dll
{GameDirectory}/{GameExeName}_Data/Managed/0Harmony.dll
{GameDirectory}/{GameExeName}_Data/Managed/ExIni.dll
{GameDirectory}/AutoTranslator/AnyTranslationFile.txt (these files will be auto generated by plugin!)
Often other mods UI are implemented through IMGUI. As you can see above, this is disabled by default. By changing the "EnableIMGUI" value to "True", it will start translating IMGUI as well, which likely means that other mods UI will be translated.
As a mod author implementing a translation plugin, 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:
As a mod author, you might not want the Auto Translator to interfere with your mods UI. If this is the case there's two ways to tell Auto Translator not to perform any translation:
If your UI is based on IMGUI, the above approach is not possible, because there are no GameObject. In that case you can do the following instead:
public class MyPlugin : XPluginBase
{
private GameObject _xua;
private bool _lookedForXua;
public void OnGUI()
{
// make sure we only do this lookup once, as it otherwise may be detrimental to performance!
// also: do not attempt to do this in the Awake method or similar of your plugin, as your plugin may be instantiated before the auto translator!
if(!_lookedForXua)
{
_lookedForXua = true;
_xua = GameObject.Find( "___XUnityAutoTranslator" );
}
// try-finally block is important to make sure you re-enable the plugin
try
{
_xua?.SendMessage("DisableAutoTranslator");
// do your GUI things here
GUILayout.Button( "こんにちは!" );
}
finally
{
_xua?.SendMessage("EnableAutoTranslator");
}
}
}
This approach requires version 2.15.0 or later!