Skip to content

Commit

Permalink
Version 4.19.0
Browse files Browse the repository at this point in the history
 * FEATURE - Added RegexPostProcessing configuration option
 * BUG FIX - Fixed bug related to reload translations after changing screen size
  • Loading branch information
randoman committed Sep 5, 2021
1 parent e646b96 commit adbef16
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 18 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
### 4.18.1
### 4.19.0
* FEATURE - Added RegexPostProcessing configuration option
* BUG FIX - Fixed bug related to reload translations after changing screen size

### 4.18.1
* BUG FIX - Fixed an unhandled exception that could occur during hook callbacks

### 4.18.0
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ TextGetterCompatibilityMode=False ;Indicates whether or not to enable "Text Gett
GameLogTextPaths= ;Indicates specific paths for game objects that the game uses as "log components", where it continuously appends or prepends text to. Requires expert knowledge to setup. This is a list seperated by ';'.
RomajiPostProcessing=ReplaceMacronWithCircumflex;RemoveApostrophes;ReplaceHtmlEntities ;Indicates what type of post processing to do on 'translated' romaji texts. This can be important in certain games because the font used does not support various diacritics properly. This is a list seperated by ';'. Possible values: ["RemoveAllDiacritics", "ReplaceMacronWithCircumflex", "RemoveApostrophes", "ReplaceHtmlEntities"]
TranslationPostProcessing=ReplaceMacronWithCircumflex;ReplaceHtmlEntities ;Indicates what type of post processing to do on translated texts (not romaji). Possible values: ["RemoveAllDiacritics", "ReplaceMacronWithCircumflex", "RemoveApostrophes", "ReplaceWideCharacters", "ReplaceHtmlEntities"]
RegexPostProcessing=None ;Indicates what type of post processing to perform on the capture groups of regexes. Possible values: ["RemoveAllDiacritics", "ReplaceMacronWithCircumflex", "RemoveApostrophes", "ReplaceWideCharacters", "ReplaceHtmlEntities"]
CacheRegexLookups=False ;Indicates whether or not results of regex lookups should be output to the specified OutputFile
CacheWhitespaceDifferences=False ;Indicates whether or not whitespace differences should be output to the specified OutputFile
CacheRegexPatternResults=False ;Indicates whether or not the complete result of regex-splitted translations should be output to the specified OutputFile
Expand Down Expand Up @@ -639,6 +640,9 @@ The group(s) `(?<stat>[\w]+)(?<num_i>[\+\-]{1}[0-9]+)?` matches the text inside

The group `(?<after>[\s\S]+)` matches whatever comes after. Because of this, it will attempt to translate that text like any other, and that may flow directly back into this splitter regex.

#### Regex Post Processing
Using the configuration option `RegexPostProcessing`, it is also possible to apply post processing the to the groups of a regex. For `sr:` regexes they are only applied to groups where the identifier name ends in `_i`.

### UI Font Resizing
It is also possible to manually control the font size of text components. This is useful when the translated text uses more space than the untranslated text.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private void CreateClientAndHandler()
_handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

_client = new HttpClient( _handler, true );
_client.DefaultRequestHeaders.UserAgent.Add( new ProductInfoHeaderValue( "XUnity", "4.18.1" ) );
_client.DefaultRequestHeaders.UserAgent.Add( new ProductInfoHeaderValue( "XUnity", "4.19.0" ) );
_client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue( "*/*" ) );
}

Expand Down
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 "4.18.1";
return "4.19.0";
}
}

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

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Version>4.18.1</Version>
<Version>4.19.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 3 additions & 7 deletions src/XUnity.AutoTranslator.Plugin.Core/Configuration/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ internal static class Settings
public static bool TextGetterCompatibilityMode;
public static TextPostProcessing RomajiPostProcessing;
public static TextPostProcessing TranslationPostProcessing;
public static TextPostProcessing RegexPostProcessing;
public static bool ForceMonoModHooks;
public static bool CacheRegexPatternResults;
public static bool CacheRegexLookups;
Expand Down Expand Up @@ -160,9 +161,6 @@ internal static class Settings
public static bool CopyToClipboard;
public static int MaxClipboardCopyCharacters;

internal static int ScreenWidth;
internal static int ScreenHeight;

public static void Configure()
{
try
Expand Down Expand Up @@ -191,10 +189,7 @@ public static void Configure()

try
{
var res = Screen.currentResolution;
ScreenWidth = res.width;
ScreenHeight = res.height;
XuaLogger.AutoTranslator.Debug( "Screen resolution determine to be: " + ScreenWidth + "x" + ScreenHeight );
XuaLogger.AutoTranslator.Debug( "Screen resolution determine to be: " + Screen.width + "x" + Screen.height );
}
catch( Exception e )
{
Expand Down Expand Up @@ -243,6 +238,7 @@ public static void Configure()
GameLogTextPaths.RemoveWhere( x => !x.StartsWith( "/" ) ); // clean up to ensure no 'empty' entries
RomajiPostProcessing = PluginEnvironment.Current.Preferences.GetOrDefault( "Behaviour", "RomajiPostProcessing", TextPostProcessing.ReplaceMacronWithCircumflex | TextPostProcessing.RemoveApostrophes | TextPostProcessing.ReplaceHtmlEntities );
TranslationPostProcessing = PluginEnvironment.Current.Preferences.GetOrDefault( "Behaviour", "TranslationPostProcessing", TextPostProcessing.ReplaceMacronWithCircumflex | TextPostProcessing.ReplaceHtmlEntities );
RegexPostProcessing = PluginEnvironment.Current.Preferences.GetOrDefault( "Behaviour", "RegexPostProcessing", TextPostProcessing.None );
CacheRegexPatternResults = PluginEnvironment.Current.Preferences.GetOrDefault( "Behaviour", "CacheRegexPatternResults", false );
CacheRegexLookups = PluginEnvironment.Current.Preferences.GetOrDefault( "Behaviour", "CacheRegexLookups", false );
CacheWhitespaceDifferences = PluginEnvironment.Current.Preferences.GetOrDefault( "Behaviour", "CacheWhitespaceDifferences", false );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public static class PluginData
/// <summary>
/// Gets the version of the plugin.
/// </summary>
public const string Version = "4.18.1";
public const string Version = "4.19.0";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using XUnity.AutoTranslator.Plugin.Core.Configuration;
using XUnity.AutoTranslator.Plugin.Core.Endpoints;
using XUnity.AutoTranslator.Plugin.Core.Utilities;
using XUnity.Common.Logging;

namespace XUnity.AutoTranslator.Plugin.Core.Parsing
Expand Down Expand Up @@ -87,7 +89,9 @@ public string GetTranslationFromParts( Func<UntranslatedTextInfo, string> getTra
if( group.Success ) // was matched
{
var value = group.Value;
var translation = ignoreTranslate ? value : getTranslation( new UntranslatedTextInfo( value ) );
var translation = ignoreTranslate
? RomanizationHelper.PostProcess( value, Settings.RegexPostProcessing )
: getTranslation( new UntranslatedTextInfo( value ) );
if( translation != null )
{
result = result.Replace( replacement, translation );
Expand Down
2 changes: 2 additions & 0 deletions src/XUnity.AutoTranslator.Plugin.Core/TextTranslationCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,7 @@ public bool TryGetTranslation( UntranslatedText key, bool allowRegex, bool allow
if( !match.Success ) continue;

value = match.Result( regex.Translation );
value = RomanizationHelper.PostProcess( value, Settings.RegexPostProcessing );

if( !Settings.EnableSilentMode ) XuaLogger.AutoTranslator.Info( $"Regex lookup: '{key.TemplatedOriginal_Text}' => '{value}'" );
AddTranslationToCache( key.TemplatedOriginal_Text, value, false, TranslationType.Full, scope );
Expand Down Expand Up @@ -1448,6 +1449,7 @@ public bool TryGetTranslation( UntranslatedText key, bool allowRegex, bool allow
if( !match.Success ) continue;

value = match.Result( regex.Translation );
value = RomanizationHelper.PostProcess( value, Settings.RegexPostProcessing );

if( !Settings.EnableSilentMode ) XuaLogger.AutoTranslator.Info( $"Regex lookup: '{key.TemplatedOriginal_Text}' => '{value}'" );
AddTranslationToCache( key.TemplatedOriginal_Text, value, Settings.CacheRegexLookups, TranslationType.Full, TranslationScopes.None );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Globalization;
using System.Linq;
using System.Text;
using UnityEngine;
using XUnity.AutoTranslator.Plugin.Core.Configuration;

namespace XUnity.AutoTranslator.Plugin.Core
Expand All @@ -18,7 +19,7 @@ internal class TranslationFileLoadingContext

public bool IsApplicable()
{
return IsValidExecutable() && _resolutionCheck( new ResolutionCheckVariables( Settings.ScreenWidth, Settings.ScreenHeight ) );
return IsValidExecutable() && _resolutionCheck( new ResolutionCheckVariables( Screen.width, Screen.height ) );
}

public bool IsValidExecutable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<DevelopmentDependency>True</DevelopmentDependency>
<TargetFramework>net35</TargetFramework>
<Version>4.18.1</Version>
<Version>4.19.0</Version>
<LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Version>4.18.1</Version>
<Version>4.19.0</Version>
</PropertyGroup>

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

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Version>4.18.1</Version>
<Version>4.19.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net40</TargetFramework>
<AssemblyName>SetupReiPatcherAndAutoTranslator</AssemblyName>
<Version>4.18.1</Version>
<Version>4.19.0</Version>
<ApplicationIcon>icon.ico</ApplicationIcon>
<Win32Resource />
</PropertyGroup>
Expand Down

0 comments on commit adbef16

Please sign in to comment.