From 11108f05659778a1730a24f63068bd44184c7815 Mon Sep 17 00:00:00 2001
From: randoman <738b86bb93c44695854182cc459afcbb@lonestar.no>
Date: Sat, 16 Feb 2019 12:16:40 +0100
Subject: [PATCH] Version 3.0.0
* FEATURE - UI to control plugin more conveniently (press ALT + 0 (that's a zero))
* FEATURE - Dynamic selection of translator during game session
* FEATURE - Support BingTranslate API
* FEATURE - Support LEC Offline Power Translator 15
* FEATURE - Enable custom implementations of translators
* FEATURE - Removed support for Excite translate because it only support the 'WWW' API in Unity due to missing Tls1.2 support
* FEATURE - Updated Watson translate to v3
* FEATURE - Support for 'romaji' as output language. Only google supports this at the moment
* FEATURE - Batching support for all endpoints where the API supports it
* BUG FIX - Too many small fixes to mention
* MISC - {GameExeName} variable can now be used in configuration of directories and files
* MISC - Changed the way the 'Custom' endpoint works. See README for more info
* MISC - Added new configuration 'GameLogTextPaths' to enable special handling of text components that text is being appended to continuously (requires export knowledge to setup)
---
README.md | 3 ++-
src/Translators/Lec.ExtProtocol/Program.cs | 2 ++
.../Endpoints/Http/HttpEndpoint.cs | 2 +-
.../Endpoints/Www/WwwEndpoint.cs | 7 ++++---
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index e4e913a7..6637c367 100644
--- a/README.md
+++ b/README.md
@@ -518,6 +518,7 @@ Often an implementation of this interface will access an external web service. I
Whenever you implement a translator based on an online service, it is important to not use it in an abusive way. For example by:
* Establishing a large number of connections to it
* Performing web scraping instead of using an available API
+ * Making concurrent requests towards it
* *This is especially important if the service is not authenticated*
With that in mind, consider the following:
@@ -653,7 +654,7 @@ For more examples of implementations, you can simply take a look at this project
**NOTE**: If you implement a class based on the `HttpEndpoint` and you get an error where the web request is never completed, then it is likely due to the web server requiring Tls1.2. Unity-mono has issues with this spec and it will cause the request to lock up forever. The only solutions to this for now are:
* Disable SSL, if you can. There are many situations where it is simply not possible to do this because the web server will simply redirect back to the HTTPS endoint.
- * Use the `WwwEndpoint` instead. I highly advice against this though, unless it is an authenticated endpoint though.
+ * Use the `WwwEndpoint` instead. I highly advice against this though, unless it is an authenticated endpoint.
Another way to implement a translator is to implement the `ExtProtocolEndpoint` class. This can be used to delegate the actual translation logic to an external process. Currently there is no documentation on this, but you can take a look at the LEC implementation, which uses it.
diff --git a/src/Translators/Lec.ExtProtocol/Program.cs b/src/Translators/Lec.ExtProtocol/Program.cs
index c3ab0c6e..de3a2a72 100644
--- a/src/Translators/Lec.ExtProtocol/Program.cs
+++ b/src/Translators/Lec.ExtProtocol/Program.cs
@@ -10,6 +10,8 @@ class Program
{
static void Main( string[] args )
{
+ // Implementation of this is based off of texel-sensei's LEC implementation
+
try
{
if( args.Length == 0 )
diff --git a/src/XUnity.AutoTranslator.Plugin.Core/Endpoints/Http/HttpEndpoint.cs b/src/XUnity.AutoTranslator.Plugin.Core/Endpoints/Http/HttpEndpoint.cs
index b3f1f4ff..d2f0513b 100644
--- a/src/XUnity.AutoTranslator.Plugin.Core/Endpoints/Http/HttpEndpoint.cs
+++ b/src/XUnity.AutoTranslator.Plugin.Core/Endpoints/Http/HttpEndpoint.cs
@@ -24,7 +24,7 @@ public abstract class HttpEndpoint : ITranslateEndpoint
/// Gets the maximum concurrency for the endpoint. This specifies how many times "Translate"
/// can be called before it returns.
///
- public virtual int MaxConcurrency => 1;
+ public int MaxConcurrency => 1;
///
/// Gets the maximum number of translations that can be served per translation request.
diff --git a/src/XUnity.AutoTranslator.Plugin.Core/Endpoints/Www/WwwEndpoint.cs b/src/XUnity.AutoTranslator.Plugin.Core/Endpoints/Www/WwwEndpoint.cs
index b7b837b5..8e756132 100644
--- a/src/XUnity.AutoTranslator.Plugin.Core/Endpoints/Www/WwwEndpoint.cs
+++ b/src/XUnity.AutoTranslator.Plugin.Core/Endpoints/Www/WwwEndpoint.cs
@@ -7,6 +7,7 @@
using Harmony;
using UnityEngine;
using XUnity.AutoTranslator.Plugin.Core.Configuration;
+using XUnity.AutoTranslator.Plugin.Core.Constants;
using XUnity.AutoTranslator.Plugin.Core.Web;
namespace XUnity.AutoTranslator.Plugin.Core.Endpoints.Www
@@ -19,7 +20,7 @@ namespace XUnity.AutoTranslator.Plugin.Core.Endpoints.Www
///
public abstract class WwwEndpoint : ITranslateEndpoint
{
- private static readonly ConstructorInfo WwwConstructor = Constants.ClrTypes.WWW.GetConstructor( new[] { typeof( string ), typeof( byte[] ), typeof( Dictionary ) } );
+ private static readonly ConstructorInfo WwwConstructor = ClrTypes.WWW.GetConstructor( new[] { typeof( string ), typeof( byte[] ), typeof( Dictionary ) } );
///
/// Gets the id of the ITranslateEndpoint that is used as a configuration parameter.
@@ -112,11 +113,11 @@ public IEnumerator Translate( ITranslationContext context )
yield return www;
// extract error
- string error = (string)AccessTools.Property( Constants.ClrTypes.WWW, "error" ).GetValue( www, null );
+ string error = (string)AccessTools.Property( ClrTypes.WWW, "error" ).GetValue( www, null );
if( error != null ) wwwContext.Fail( "Error occurred while retrieving translation. " + error );
// extract text
- var text = (string)AccessTools.Property( Constants.ClrTypes.WWW, "text" ).GetValue( www, null );
+ var text = (string)AccessTools.Property( ClrTypes.WWW, "text" ).GetValue( www, null );
if( text == null ) wwwContext.Fail( "Error occurred while extracting text from response." );
wwwContext.ResponseData = text;