Skip to content

Commit

Permalink
Version 3.0.0
Browse files Browse the repository at this point in the history
 * 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)
  • Loading branch information
randoman committed Feb 16, 2019
1 parent 31c2ef5 commit 11108f0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions src/Translators/Lec.ExtProtocol/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
public virtual int MaxConcurrency => 1;
public int MaxConcurrency => 1;

/// <summary>
/// Gets the maximum number of translations that can be served per translation request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,7 +20,7 @@ namespace XUnity.AutoTranslator.Plugin.Core.Endpoints.Www
/// </summary>
public abstract class WwwEndpoint : ITranslateEndpoint
{
private static readonly ConstructorInfo WwwConstructor = Constants.ClrTypes.WWW.GetConstructor( new[] { typeof( string ), typeof( byte[] ), typeof( Dictionary<string, string> ) } );
private static readonly ConstructorInfo WwwConstructor = ClrTypes.WWW.GetConstructor( new[] { typeof( string ), typeof( byte[] ), typeof( Dictionary<string, string> ) } );

/// <summary>
/// Gets the id of the ITranslateEndpoint that is used as a configuration parameter.
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 11108f0

Please sign in to comment.