TORRENT – FREE DOWNLOAD – CRACKED
Sep 29, 2018 The cirlce had caught modder & fan translator eyes' with it's last two game, so there is a possibility that at some point some mod and / or translation appear, but be patient - the last game fan translation took nearly 1 year for completion. More: English to English translation of Insult An insult is an expression, statement (or sometimes behavior) which is disrespectful or scornful. Insults may be intentional or accidental.
INSULT ORDER ~Cocky Cat Girls’ Pleasure Corruption is on the Menu~ – Hardcore Real-Time 3D! Let’s train heroines as you like DLsite Adult Doujin is a download shop for…
Game Overview
* Story There is a luxury nightclub with demi-human hostesses known as “Demi-Stage Cafe”. In the guise of a restaurant, the hostesses provide customers with sexual service. Let’s train the hostesses in your favorite ways with lewd orders in your hands. – Hardcore Realtime 3D! – Every single sex position is elaborated in pursuit of the quality! – Presented with lots of different situations, including abnormal ones. A huge volume! – Massive bukkake with well-depicted sperm fluid!! – It’s moving! On/Off X-ray view is selectable. – Real-time events make you deeply…
INSULT ORDER ~Cocky Cat Girls’ Pleasure Corruption is on the Menu~
miconisomi
miconisomi
Sep/28/2018
Adult, Anime, Mature, Nudity, Visual Novel
DOWNLOAD LINKS
INSULT ORDER Cocky Cat Girls Pleasure Corruption is on the Menu
P2P
2.48 GB
TORRENT LINK
System Requirement
Minimum:
- CPU: intel core i5 or greater recommended
- Memory: 4.0GB+ available space
- HDD: 10GB or more remaining space
- Video: nVIDIA GeForce450 or greater required
- DirectX: 11
Insult Order Crack, Insult Order DLC Download, Insult Order Free Download, Insult Order REPACK, Insult Order Torrent
Index
Introduction
This is a plugin that is capable of using various online translators to provide on-the-fly translations for various Unity-based games.
It does (obviously) go to the internet, in order to provide the translation, so if you are not comfortable with that, don't use it.
Oh, and it is also capable of doing some basic image loading/dumping. Go to the Texture Translation section to find out more.
If you intend on redistributing this plugin as part of a translation suite for a game, please read this section.
From version 3.0.0 it is possible to implement custom translators. See this section for more info.
Plugin Frameworks
The mod can be installed into the following Plugin Managers:
- BepInEx (recommended approach)
- UnityInjector
Installation instructions for all 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!
Installation
The plugin can be installed in following ways:
BepInEx (4.x) Plugin
REQUIRES: BepInEx plugin manager (follow its installation instructions first!).
- Download XUnity.AutoTranslator-BepIn-{VERSION}.zip from releases.
- Extract directly into the game directory, such that the plugin dlls are placed in BepInEx folder.
The file structure should like like this:
BepInEx (5.x) Plugin
REQUIRES: BepInEx plugin manager (follow its installation instructions first!).
- Download XUnity.AutoTranslator-BepIn-5x-{VERSION}.zip from releases.
- Extract directly into the game directory, such that the plugin dlls are placed in BepInEx folder.
The file structure should like like this:
IPA Plugin
REQUIRES: IPA plugin manager (follow its installation instructions first!).
- Download XUnity.AutoTranslator-IPA-{VERSION}.zip from releases.
- Extract directly into the game directory, such that the plugin dlls are placed in Plugins folder.
The file structure should like like this
UnityInjector Plugin
REQUIRES: UnityInjector (follow its installation instructions first!).
- Download XUnity.AutoTranslator-UnityInjector-{VERSION}.zip from releases.
- Extract directly into the game directory, such that the plugin dlls are placed in UnityInjector folder. This may not be game root directory!
The file structure should like like this
Standalone Installation (ReiPatcher)
REQUIRES: Nothing, ReiPatcher is provided by this download.
NOTE: Only use this installation method if you are not using one of the above plugin managers!
- Download XUnity.AutoTranslator-ReiPatcher-{VERSION}.zip from releases.
- Extract directly into the game directory, such that 'SetupReiPatcherAndAutoTranslator.exe' is placed alongside other exe files.
- Execute 'SetupReiPatcherAndAutoTranslator.exe'. This will setup up ReiPatcher correctly.
- Execute the shortcut {GameExeName} (Patch and Run).lnk that was created besides existing executables. This will patch and launch the game.
- From now on you can launch the game from the {GameExeName}.exe instead.
The file structure should like like this
Key Mapping
The following key inputs are mapped:
- ALT + 0: Toggle XUnity AutoTranslator UI. (That's a zero, not an O)
- ALT + 1: Toggle Translation Aggregator UI.
- ALT + T: Alternate between translated and untranslated versions of all texts provided by this plugin.
- ALT + R: Reload translation files. Useful if you change the text and texture files on the fly. Not guaranteed to work for all textures.
- ALT + U: Manual hooking. The default hooks wont always pick up texts. This will attempt to make lookups manually.
- ALT + F: If OverrideFont is configured, will toggle between overridden and default font.
- ALT + Q: Reboot the plugin if it was shutdown. This will only work if the plugin was shut down due to consecutive errors towards the translation endpoint. Should only be used if you have reason to believe you have remedied the problem (such as changed VPN endpoint etc.) otherwise it will just shut down again.
Translators
The supported translators are:
- GoogleTranslate, based on the online Google translation service. Does not require authentication.
- No limitations, but unstable.
- GoogleTranslateLegitimate, based on the Google cloud translation API. Requires an API key.
- Provides trial period of 1 year with $300 credits. Enough for 15 million characters translations.
- BingTranslate, based on the online Bing translation service. Does not require authentication.
- No limitations, but unstable.
- BingTranslateLegitimate, based on the Azure text translation. Requires an API key.
- Free up to 2 million characters per month.
- PapagoTranslate, based on the online Google translation service. Does not require authentication.
- No limitations, but unstable.
- BaiduTranslate, based on Baidu translation service. Requires AppId and AppSecret.
- Not sure on quotas on this one.
- YandexTranslate, based on the Yandex translation service. Requires an API key.
- Free up to 1 million characters per day, but max 10 million characters per month.
- WatsonTranslate, based on IBM's Watson. Requires a URL and an API key.
- Free up to 1 million characters per month.
- LecPowerTranslator15, based on LEC's Power Translator. Does not require authentication, but does require the software installed.
- No limitations.
- CustomTranslate. Alternatively you can also specify any custom HTTP url that can be used as a translation endpoint (GET request). This must use the query parameters 'from', 'to' and 'text' and return only a string with the result (try HTTP without SSL first, as unity-mono often has issues with SSL).
- NOTE: This is a developer-centric option. You cannot simply specify 'CustomTranslate' and expect it to work with any arbitrary translation service you find online. See FAQ
- Example Configuration:
- Endpoint=CustomTranslate
- [Custom]
- Url=http://my-custom-translation-service.net/translate
- Example Request: GET http://my-custom-translation-service.net/translate?from=ja&to=en&text=こんにちは
- Example Response (only body): Hello
NOTE: If you use any of the online translators that does not require some form of authentication, that this plugin may break at any time.
Since 3.0.0, you can also implement your own translators. To do so, follow the instruction here.
About Authenticated Translators
If you decide to use an authenticated service do not ever share your key or secret. If you do so by accident, you should revoke it immediately. Most, if not all services provides an option for this.
Also, make sure you monitor the service's request usage/quotas, especially when it is being used with unknown games. This plugin makes no guarantees about how many translation requests will be sent out, although it will attempt to keep the number to a minimum. It does so by using the spam prevention mechanisms discussed below.
Spam Prevention
The plugin employs the following spam prevention mechanisms:
- When it sees a new text, it will always wait one second before it queues a translation request, to check if that same text changes. It will not send out any request until the text has not changed for 1 second. (Utage (VN Game Engine) is an exception here, as those texts may come from a resource lookup)
- It will never send out more than 8000 requests (max 200 characters each (configurable)) during a single game session.
- It will never send out more than 1 request at a time (no concurrency!).
- If it detects an increasing number of queued translations (4000), the plugin will shutdown.
- If the service returns no result for five consecutive requests, the plugin will shutdown.
- If the plugin detects that the game queues translations every frame, the plugin will shutdown after 90 frames.
- If the plugin detects text that 'scrolls' into place, the plugin will shutdown. This is detected by inspecting all requests that are queued for translation. ((1) will genenerally prevent this from happening)
- If the plugin consistently queues translations every second for more than 60 seconds, the plugin will shutdown.
- For the supported languages, each translatable line must pass a symbol check that detects if the line includes characters from the source language.
- It will never attempt a translation for a text that is already considered a translation for something else.
- All queued translations are kept track of. If two different components that require the same translation and both are queued for translation at the same time, only a single request is sent.
- It employs an internal dictionary of manual translations (~10000 in total) for commonly used phrases (Japanese-to-English only) to prevent sending out translation requests for these.
- Some endpoints support batching of translations so far fewer requests are sent. This does not increase the total number of translations per session (2).
- All translation results are cached in memory and stored on disk to prevent making the same translation request twice.
- Due to its spammy nature, any text that comes from an IMGUI component has any numbers found in it templated away (and substituted back in upon translation) to prevent issues in relation to (6).
- The plugin will keep a single TCP connection alive towards the translation endpoint. This connection will be gracefully closed if it is not used for 50 seconds.
Text Frameworks
The following text frameworks are supported.
- IMGUI (disabled by default)
Configuration
The default configuration file, looks as such:
Behaviour Configuration Explanation
Whitespace Handling
When it comes to automated translations, proper whitespace handling can really make or break the translation. The parameters that control whitespace handling are:
IgnoreWhitespaceInDialogue
IgnoreWhitespaceInNGUI
MinDialogueChars
ForceSplitTextAfterCharacters
WhitespaceRemovalStrategy
The plugin first determines whether or not it should perform a special whitespace removal operation. How it removes the whitespace is based on the parameter
WhitespaceRemomvalStrategy
. The default value of this parameter is recommended. The other option 'None' may cause poor translations.It determines whether or not to perform this operation based on the parameters
IgnoreWhitespaceInDialogue
, IgnoreWhitespaceInNGUI
and MinDialogueChars
:IgnoreWhitespaceInDialogue
: If the text is longer thanMinDialogueChars
, whitespace is removed.IgnoreWhitespaceInNGUI
: If the text comes from an NGUI component, whitespace is removed.
It is worth mentioning if the same whitespace character is repeating in the untranslated text, it will not be removed because it is likely used for formatting.
All leading and trailing whitespace before the actual text is preserved in the translation as well. But the plugin will still be capable of reading a translation from the translation file, even if the leading/trailing whitespace does not match up exactly.
![Order Order](/uploads/1/2/5/5/125591576/116988290.jpg)
After the text has been translated by the configured service,
ForceSplitTextAfterCharacters
is used to determine if the plugin should force the result into multiple lines after a certain number of characters.The main reason that this type of handling can make or break a translation really comes down to whether or not whitespace is removed from the source text before sending it to the endpoint. Most endpoints (such as GoogleTranslate) consider text on multiple lines seperately, which can often result in terrible translation if an unnecessary newline is included.
UI Resizing
Often when performing a translation on a text component, the resulting text is larger than the original. This often means that there is not enough room in the text component for the result. This section describes ways to remedy that by changing important parameters of the text components.
The important parameters in relation to this are
EnableUIResizing
, ResizeUILineSpacingScale
, ForceUIResizing
and OverrideFont
.EnableUIResizing
: Resizes the components when a translation is performed.ForceUIResizing
: Resizes all components at all times, period.ResizeUILineSpacingScale
: Changes the line spacing of resized components. UGUI only.OverrideFont
: Changes the font of all text components regardless ofEnableUIResizing
andForceUIResizing
. UGUI only.
Resizing of a UI component does not refer to changing of it's dimensions, but rather how the component handles overflow. The plugin changes the overflow parameters such that text is more likely to be displayed.
Reducing Translation Requests
The following aims at reducing the number of requests send to the translation endpoint:
EnableBatching
: Batches several translation requests into a single with supported endpoints.UseStaticTranslations
: Enables usage of internal lookup dictionary of various english-to-japanese terms.MaxCharactersPerTranslation
: Specifies the maximum length of a text to translate. Any texts longer than this is ignored by the plugin. Cannot be greater than 500.
Romaji 'translation'
One of the possible values as output
Language
is 'romaji'. If you choose this as language, you will find that games often has problems showing the translations because the font does not understand the special characters used, for example the macron diacritic.To rememdy this, post processing can be applied to translations when 'romaji' is chosen as
Language
. This is done through the option RomajiPostProcessing
. This option is a ';'-seperated list of values:RemoveAllDiacritics
: Remove all diacritics from the translated textReplaceMacronWithCircumflex
: Replaces the macron diacritic with a circumflex.RemoveApostrophes
: Some translators might decide to include apostrophes after the 'n'-character. Applying this option removes those.
This type of post processing is also applied to normal translations, but instead uses the option
TranslationPostProcessing
, which can use the same values.Experimental Hooks
Experimental hooks are hooks are created at runtime, but not through the Harmony dependency. Harmony has two primary problems that these hooks attempt to solve:
- Harmony cannot hook methods with no body.
- Harmony cannot hook methods under the
netstandard2.0
API surface, which later versions of Unity can be build under.
The experimental hooks implemented in this library can do this. However, unless it is absolutely required by the game, it is not recommended to enable them.
The following configuration controls the experimental hooks:
EnableExperimentalHooks
: Will allow the plugin to use these hooks, if a standard Harmony hook cannot be applied.ForceExperimentalHooks
: Forces the plugin to use experimental hooks over Harmony hooks.EnableExperimentalHooks
must also be enabled for this to work. Only used for debugging.
Other Options
TextGetterCompatibilityMode
: This mode fools the game into thinking that the text displayed is not translated. This is required if the game uses text displayed to the user to determine what logic to execute. You can easily determine if this is required if you can see the functionality works fine if you toggle the translation off (hotkey: ALT+T).IgnoreTextStartingWith
: Disable translation for any texts starting with values in this ';-separated' setting. The default value is an invisible character that takes up no space.CopyToClipboard
: Copy text to translate to the clipboard to support tools such as Translation Aggregator.Delay
: Required delay from a text appears until a translation request is queued in seconds. IMGUI not supported.
Frequently Asked Questions
Q: Why doesn't this plugin work in game X?
A: If the plugin does not work in a game, you can try to set the following configuration parameter
A: If the plugin does not work in a game, you can try to set the following configuration parameter
DisableCertificateValidation=True
. If it still does not work, it likely uses a technique to display text that this plugin is not aware of. In that case you can make an issue and maybe it will get fixed in a later version.Q: The game stops working when this plugin applies translations.
A: Try setting the following configuration parameter
A: Try setting the following configuration parameter
TextGetterCompatibilityMode=True
.Q: Can this plugin translate other plugins/mods?
A: Likely yes, see here.
A: Likely yes, see here.
Q: How do I use CustomTranslate?
A: If you have to ask, you probably can't. CustomTranslate is intended for developers of a translation service. They would be able to expose an API that conforms to CustomTranslate's API specification without needing to implement a custom ITranslateEndpoint in this plugin as well.
A: If you have to ask, you probably can't. CustomTranslate is intended for developers of a translation service. They would be able to expose an API that conforms to CustomTranslate's API specification without needing to implement a custom ITranslateEndpoint in this plugin as well.
Q: Please provide support for translation service X.
A: For now, additional support for services that does not require some form of authentication is unlikely. Do note though, that it is possible to implement custom translators independently of this plugin. And it takes remarkably little code to do so.
A: For now, additional support for services that does not require some form of authentication is unlikely. Do note though, that it is possible to implement custom translators independently of this plugin. And it takes remarkably little code to do so.
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.
This may seem like a nice feature to have enabled by default but never redistribute the mod with this enabled. The reason here being that IMGUI has a very spammy nature. This does not mean that IMGUI in general will spam the endpoint, just that it is more likely to cause spam (and therefore cause the plugin to shutdown).
Manual Translations
When you use this plugin, you can always go to the file
Translation_AutoGeneratedTranslations.{lang}.txt
(OutputFile) to edit any auto generated translations and they will show up the next time you run the game. Or you can press (ALT+R) to reload the translation immediately.It is also worth noting that this plugin will read all text files (*.txt) in the
Translation
(Directory), so if you want to provide a manual translation, you can simply cut out texts from the Translation_AutoGeneratedTranslations.{lang}.txt
(OutputFile) and place them in new text files in order to replace them with a manual translation.In this context, the
Translation_AutoGeneratedTranslations.{lang}.txt
(OutputFile) will always have the lowest priority when reading translations. So if the same translation is present in two places, it will not be the one from the (OutputFile) that is used.Substitutions
It is also possible to add substitutions that are applied to found texts before translations are created. This is controlled through the
SubstitutionFile
, which uses the same format as normal translation text files, although things like regexes are not supported.This is useful for replacing names that are often translated incorrectly, etc.
When using substitutions, the found occurrences will be parameterized in the generated translations, like so:
Alternatively, if the configuration
GenerateStaticSubstitutionTranslations=True
is used the translations will not be parameterized.When creating manual translations, use this file as sparingly as you would use regexes, as it can have an effect on performance.
NOTE: If the text to be translated includes rich text, it cannot currently be parameterized.
Regarding Redistribution
Redistributing this plugin for various games is absolutely encouraged. However, if you do so, please keep the following in mind:
- Distribute the _AutoGeneratedTranslations.{lang}.txt file along with the redistribution with as many translations as possible to ensure the online translator is hit as little as possible.
- Test your redistribution with logging/console enabled to ensure the game does not exhibit undesirable behaviour such as spamming the endpoints.
- Ensure you keep the plugin up-to-date, as much as reasonably possible.
- If you use image loading feature, make sure you read this section.
Texture Translation
From version 2.16.0+ this mod provides basic capabilities to replace images. It is a feature that is disabled by default. There is no automatic translation of these images though.
This feature is primarily meant for games with little to no mod support to enable full translations without needing to modify resource files.
It is controlled by the following configuration:
TextureDirectory
specifies the directory where textures are dumped to and loaded from. Loading will happen from all subdirectories of the specified directory as well, so you can move dumped images to whatever folder structure you desire.EnableTextureTranslation
enables texture translation. This basically means that textures will be loaded from the TextureDirectory
and it's subsdirectories. These images will replace the in-game images used by the game.EnableTextureDumping
enables texture dumping. This means that the mod will dump any images it has not already dumped to the TextureDirectory
. When dumping textures, it may also be worth enabling EnableTextureScanOnSceneLoad
to more quickly find all textures that require translating. Never redistribute the mod with this enabled.EnableTextureScanOnSceneLoad
allows the plugin to scan for texture objects on the sceneLoad event. This enables the plugin to find more texture at a tiny performance cost during scene load (which is often during loading screens, etc.). However, because of the way Unity works not all of these are guaranteed to be replacable. If you find an image that is dumped but cannot be translated, please report it. However, please recognize this mod is primarily intended for replacing UI textures, not textures for 3D meshes.EnableSpriteRendererHooking
allows the plugin to attempt to hook SpriteRenderer. This is a seperate option because SpriteRenderer can't actually be hooked properly and the implemented workaround could have a theoretical impact on performance in certain situations.LoadUnmodifiedTextures
enables whether or not the plugin should load textures that has not been modified. This is only useful for debugging, and likely to cause various visual glitches, especially if EnableTextureScanOnSceneLoad
is also enabled. Never redistribute the mod with this enabled.EnableTextureToggling
enables whether the ALT+T hotkey will also toggle textures. This is by no means guaranteed to work, especially if EnableTextureScanOnSceneLoad
is also enabled. Never redistribute the mod with this enabled.DuplicateTextureNames
specifies different textures in the game that are used under the same resource name. The plugin will fallback to the 'FromImageData' for image identification for these images.DetectDuplicateTextureNames
specifies that the plugin should identify which image names are duplicated and update the configuration with these names automatically. Never redistribute the mod with this enabled.TextureHashGenerationStrategy
specifies how images are identified. When images are stored, the game will need some way of associating them with the image that it has to replace.This is done through a hash-value that is stored in square brackets in each image file name, like this: file_name [0223B639A2-6E698E9272].png
. This configuration specifies how these hash-values are generated:FromImageName
means that the hash is generated from the internal resource name that the game uses for the image, which may not exist for all images or even be unique. However, it is generally fairly reliable. If an image has no resource name, it will not be dumped.FromImageData
means that the hash is generated from the data stored in the image, which is guaranteed to exist for all images. However, generating the hash comes at a performance cost, that will also be incurred by the end-users.FromImageNameAndScene
means that it should use the name and scene to generate a hash. The name is still required for this to work. When using this option, there is a chance the same texture could be dumped with different hashes, which is undesirable, but it could be required for some games, if the name itself is not unique and theFromImageData
option causes performance issues. If this is used, it is recommended to enableEnableTextureScanOnSceneLoad
as well.
There's an important catch you need to be aware when dealing with these options and that is if ANY of these options exists:
EnableTextureDumping=True
, EnableTextureToggling=True
, TextureHashGenerationStrategy=FromImageData
, then the game will need to read the raw data from all images it finds in game in order to replace the image and this is an expensive operation.It is therefore recommended to use
TextureHashGenerationStrategy=FromImageName
. Most likely, images without a resource name won't be interesting to translate anyway.If you redistribute this mod with translated images, it is recommended you delete all images you either have no intention of translating or are not translated at all.
You can also change the file name to whatever you desire, as long as you keep the hash appended to the end of the file name.
If you take anything away from this section, it should be these two points:
- Never redistribute the mod with
EnableTextureDumping=True
,EnableTextureToggling=True
,LoadUnmodifiedTextures=True
orDetectDuplicateTextureNames=true
- Only redistribute the mod with
TextureHashGenerationStrategy=FromImageData
enabled if absolutely required by the game.
Technical details about Hash Generation in file names
There are actually two hashes in the generated file name, separated by a dash (-):
- The first hash is a SHA1 (only first 5 bytes) based on the
TextureHashGenerationStrategy
used. IfFromImageName
is specified, then it is based on the UTF8 (without BOM) representation. - The second hash is a SHA1 (only first 5 bytes) based on the data in the image. This is used to determine whether or not the image has been modified, so images that has not been edited are not loaded. Unless
LoadUnmodifiedTextures
is specified.
If
TextureHashGenerationStrategy=FromImageData
is specified, only a single hash will appear in each file name, as that single hash can be used both to identify the image and to determine whether or not it has been edited.Integrating with Auto Translator
NOTE: Everything below this point requires programming knowledge!
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.
- 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:
- The component that represents the text in the UI. (The one that probably has a property called 'text').
- The untranslated text
- 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:
- UGUI: public static event Func<object, string, string> OnUnableToTranslateUGUI
- TextMeshPro: public static event Func<object, string, string> OnUnableToTranslateTextMeshPro
- NGUI: public static event Func<object, string, string> OnUnableToTranslateNGUI
- IMGUI: public static event Func<object, string, string> OnUnableToTranslateIMGUI
- Also, the events can be either instance based or static.
Be aware that if you do this, that the hooking functionality of the Auto Translator itself will be disabled. So you are entirely responsible for implementing the required hooks for the overriden text framework.
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:
This approach requires version 2.15.0 or later!
Implementing a Translator
Since version 3.0.0, you can now also implement your own translators.
In order to do so, all you have to do is implement the following interface, build the assembly and place the generated DLL in the
Translators
folder.Often an implementation of this interface will access an external web service. If this is the case, you do not need to implement the entire interface yourself. Instead you can rely on a base class in the
XUnity.AutoTranslator.Plugin.Core
assembly. But more on this later.Important Notes on Implementing a Translator based on an Online Service
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:
- The
WWW
class in Unity establishes a new TCP connection on each request you make, making it extremely poor at this kind of job. Especially if SSL (https) is involved because it has to do the entire handshake procedure each time. Yuck. - The
UnityWebRequest
class in Unity does not exist in most games, because the authors use an old engine, so it is not a good choice either. - The
WebClient
class from .NET is capable of using persistent connections (it does so by default), but has its own problems with SSL. The version of Mono used in most Unity games rejects all certificates by default making all HTTPS connections fail. This, however, can be remedied during the initialization phase of the translator (see examples below). Another shortcoming of this API is the fact that the runtime will never release the TCP connections it has used until the process ends. The API also integrates terribly with Unity because callbacks return on a background thread. - The
WebRequest
class from .NET is essentially the same as WebClient. - The
HttpClient
class from .NET is also unlikely to exist in most Unity games.
None of these are therefore an ideal solution.
To remedy this, the plugin implements a class
XUnityWebClient
, which is based on Mono's version of WebClient. However, it adds the following features:- Enables integration with Unity by returning result classes that can be 'yielded'.
- Properly closes connections that has not been used for 50 seconds.
I recommend using this class, or in case that cannot be used, falling back to the .NET 'WebClient'.
How-To
Follow these steps:
- Download XUnity.AutoTranslator-Developer-{VERSION}.zip from releases
- Start a new project (.NET 3.5) in Visual Studio 2017 or later. I recommend using the same name for your assembly/project as the 'Id' you are going to use in your interface implementation. This makes it easier for users to know how to configure your translator
- I recommend using the 'Class Library (.NET Standard)' and simply editing the generated .csproj file to use 'net35' instead of 'netstandard2.0'. This generates much cleaner .csproj files.
- Add a reference to the XUnity.AutoTranslator.Plugin.Core.dll that you downloaded in step 1
- You do not need to directly reference the UnityEngine.dll assembly. This is good, because you do not need to worry about which version of Unity is used.
- If you do need a reference to this assembly (because you need functionality from it) consider using an old version of it (if
UnityEngine.CoreModule.dll
exists in the Managed folder, it is not an old version!)
- If you do need a reference to this assembly (because you need functionality from it) consider using an old version of it (if
- Create a new class that either:
- Implements the
ITranslateEndpoint
interface - Inherits from the
HttpEndpoint
class - Inherits from the
WwwEndpoint
class - Inherits from the
ExtProtocolEndpoint
class
- Implements the
Here's an example that simply reverses the text and also reads some configuration from the configuration file the plugin uses:
Arguably, this is not a particularly interesting example, but it illustrates the basic principles of what must be done in order to implement a Translator.
Let's take a look at a more advanced example that accesses the web:
This plugin extends from
HttpEndpoint
. Let's look at the three methods it overrides:Initialize
is used to read the API key the user has configured. In addition it callscontext.DisableCertificateChecksFor( 'translate.yandex.net' )
in order to disable the certificate check for this specific hostname. If this is neglected, SSL will fail in most versions of Unity. Finally, it throws an exception if the plugin cannot be used with the specified configuration.OnCreateRequest
is used to construct theXUnityWebRequest
object that will be sent to the external endpoint. The call tocontext.Complete( request )
specifies the request to use.OnExtractTranslation
is used to extract the text from the response returned from the web server.
As you can see, the
XUnityWebClient
class is not even used. We simply specify a request object that the HttpEndpoint
will use internally to perform the request.After implementing the class, simply build the project and place the generated DLL file in the 'Translators' directory of the plugin folder. That's it.
For more examples of implementations, you can simply take a look at this projects source code.
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.
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.If instead, you use the interface directly, it is also possible to extend from MonoBehaviour to get access to all the normal lifecycle callbacks of Unity components.