Skip to content

Commit

Permalink
Update 2.15.0
Browse files Browse the repository at this point in the history
implemented manual hooking
implemented integration options for other plugins  to disable this plugin
generally improved hooking capability to support additional software
fixed rich text bug as it relates to "ruby" and "group" tags
  • Loading branch information
randoman committed Sep 9, 2018
1 parent c95f883 commit 8f538c5
Show file tree
Hide file tree
Showing 20 changed files with 238 additions and 85 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
### 2.14.1
### 2.15.0
* FEATURE - Manual hooking - press ALT + U. This will lookup all game objects and attempt translation immediately
* FEATURE - Capability for other plugins to tell the Auto Translator not to translate texts
* BUG FIX - Initialization hooking that will attempt to hook any game object that was missed during game initialization
* BUG FIX - Minor fixes to handling of rich text to better support tags that should be ignored, such as ruby, group
* MISC - Generally better hooking capabilities

### 2.14.1
* BUG FIX - Never allow text to be queued for translation before stabilization check for rich text
* MISC - Improved a spam detection check

Expand Down
54 changes: 47 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The default configuration file, looks as such (2.6.0+):

```ini
[Service]
Endpoint=GoogleTranslate ;Endpoint to use. Can be ["GoogleTranslate", "GoogleTranslateLegitimate", "BaiduTranslate", "YandexTranslate", "WatsonTranslate", "ExciteTranslate"]
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
Expand Down Expand Up @@ -91,6 +91,7 @@ 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.
* ALT + U: Manual hooking. The default hooks wont always pick up texts. This will attempt to make lookups manually.

## Installation
The plugin can be installed in following ways:
Expand All @@ -106,7 +107,7 @@ 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 (this files will be auto generated by plugin!)
{GameDirectory}/BepInEx/Translation/AnyTranslationFile.txt (these files will be auto generated by plugin!)
```

### IPA Plugin
Expand All @@ -121,7 +122,7 @@ The file structure should like like this
{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!)
{GameDirectory}/Plugins/Translation/AnyTranslationFile.txt (these files will be auto generated by plugin!)
```

### UnityInjector Plugin
Expand All @@ -136,7 +137,7 @@ The file structure should like like this
{GameDirectory}/UnityInjector/XUnity.AutoTranslator.Plugin.Core.UnityInjector.dll
{GameDirectory}/UnityInjector/0Harmony.dll
{GameDirectory}/UnityInjector/ExIni.dll
{GameDirectory}/UnityInjector/Translation/AnyTranslationFile.txt (this files will be auto generated by plugin!)
{GameDirectory}/UnityInjector/Translation/AnyTranslationFile.txt (these files will be auto generated by plugin!)
```

### Standalone Installation (ReiPatcher)
Expand All @@ -162,16 +163,16 @@ The file structure should like like this
{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 (this files will be auto generated by plugin!)
{GameDirectory}/AutoTranslator/AnyTranslationFile.txt (these files will be auto generated by plugin!)
```

## Translating Mods
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.

## 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.
### Implementing a dedicated translation component
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:
* You must implement a Component (MonoBehaviour for instance) that this plugin is able to locate by simply traversing all objects during startup.
Expand All @@ -185,3 +186,42 @@ Here's how it works, and what is required:
3. NGUI: public static event Func<object, string, string> OnUnableToTranslateNGUI
3. IMGUI: public static event Func<object, string, string> OnUnableToTranslateIMGUI
* Also, the events can be either instance based or static.

### Implementing a component that the Auto Translator should not interfere with
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 GameObjects, you can simply name your GameObjects containing the text element (for example Text class) to something that contains the string "XUAIGNORE". The Auto Translator will check for this and ignore components that contains the string.
* 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:

```C#
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!
2 changes: 1 addition & 1 deletion src/XUnity.AutoTranslator.Patcher/Patcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override string Version
{
get
{
return "2.14.1";
return "2.15.0";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Version>2.14.1</Version>
<Version>2.15.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 8f538c5

Please sign in to comment.