Skip to content

Commit

Permalink
Version 4.7.1 (Auto Translator)
Browse files Browse the repository at this point in the history
 * BUG FIX - Development-time fix to the nuget package
 * BUG FIX - The 'Translators' directory must now be placed in the same directory that the XUnity.AutoTranslator.Plugin.Core.dll is placed in. This allows moving around the plugin as you see fit in BepInEx 5.0. For the ReiPatcher installer, the Translators are now found in the Managed directory of the game. For UnityInjector the Translators directory has been moved out of the Config directory
 * BUG FIX - Minor bug fix where in some cases the plugin could not create the initial translation files on startup

Version 1.1.1 (Resource Redirector)

 * BUG FIX - Development-time fix to the nuget package
  • Loading branch information
randoman committed Nov 27, 2019
1 parent 1d4689e commit 8856468
Show file tree
Hide file tree
Showing 34 changed files with 137 additions and 65 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG - ResourceRedirector.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
### 1.1.0
### 1.1.1
* BUG FIX - Development-time fix to the nuget package

### 1.1.0
* FEATURE - Added method to load an asset from a file, with fallback to loading it from an in-memory stream with randomized CAB
* FEATURE - Added support for postfix hooks on AssetBundle loads
* FEATURE - Added hook for 'LoadFromMemory' and 'LoadFromMemoryAsync' when loading asset bundles
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
### 4.7.0
### 4.7.1
* BUG FIX - Development-time fix to the nuget package
* BUG FIX - The 'Translators' directory must now be placed in the same directory that the XUnity.AutoTranslator.Plugin.Core.dll is placed in. This allows moving around the plugin as you see fit in BepInEx 5.0. For the ReiPatcher installer, the Translators are now found in the Managed directory of the game. For UnityInjector the Translators directory has been moved out of the Config directory
* BUG FIX - Minor bug fix where in some cases the plugin could not create the initial translation files on startup

### 4.7.0
* FEATURE - Text preprocessors that allows applying text replacements before a text is sent for translation
* MISC - Changed a lot of logging levels and changed SilentMode to default to true

Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The file structure should like like this
{GameDirectory}/{GameExeName}_Data/Managed/Mono.Cecil.dll
{GameDirectory}/{GameExeName}_Data/Managed/0Harmony.dll
{GameDirectory}/{GameExeName}_Data/Managed/ExIni.dll
{GameDirectory}/AutoTranslator/Translators/{Translator}.dll
{GameDirectory}/{GameExeName}_Data/Managed/Translators/{Translator}.dll
{GameDirectory}/AutoTranslator/Translation/AnyTranslationFile.txt (these files will be auto generated by plugin!)
```

Expand Down Expand Up @@ -162,7 +162,7 @@ The file structure should like like this
{GameDirectory}/UnityInjector/XUnity.AutoTranslator.Plugin.UnityInjector.dll
{GameDirectory}/UnityInjector/XUnity.AutoTranslator.Plugin.ExtProtocol.dll
{GameDirectory}/UnityInjector/0Harmony.dll
{GameDirectory}/UnityInjector/Config/Translators/{Translator}.dll
{GameDirectory}/UnityInjector/Translators/{Translator}.dll
{GameDirectory}/UnityInjector/Config/Translation/AnyTranslationFile.txt (these files will be auto generated by plugin!)
```

Expand Down Expand Up @@ -267,6 +267,7 @@ FromLanguage=ja ;The original language of the game
Directory=Translation\{Lang}\Text ;Directory to search for cached translation files. Can use placeholder: {GameExeName}, {Lang}
OutputFile=Translation\{Lang}\Text\_AutoGeneratedTranslations.txt ;File to insert generated translations into. Can use placeholders: {GameExeName}, {Lang}
SubstitutionFile=Translation\{Lang}\Text\_Substitutions.txt ;File that contains substitution applied before translations. Can use placeholders: {GameExeName}, {Lang}
PreprocessorsFile=Translation\{Lang}\Text\_Preprocessors.txt ;File that contains preprocessors to be applied before sending a text to a translator. Can use placeholders: {GameExeName}, {Lang}

[TextFrameworks]
EnableUGUI=True ;Enable or disable UGUI translation
Expand Down Expand Up @@ -387,6 +388,11 @@ After the text has been translated by the configured service, `ForceSplitTextAft

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.

#### Text pre-processing
While proper whitespace handling goes a long way in ensuring better translations, it is not always enough.

The `PreprocessorsFile` allows defining entries that modifies the text just before it is sent to the translator.

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override void Initialize( IInitializationContext context )

if( string.IsNullOrEmpty( pathToLec ) ) throw new EndpointInitializationException( "The LecPowerTranslator15 requires the path to the installation folder." );

var exePath = Path.Combine( context.PluginDirectory, @"Translators\FullNET\Lec.ExtProtocol.exe" );
var exePath = Path.Combine( context.TranslatorDirectory, @"FullNET\Lec.ExtProtocol.exe" );

var fileExists = File.Exists( exePath );
if( !fileExists ) throw new EndpointInitializationException( $"Could not find any executable at '{exePath}'" );
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.7.0";
return "4.7.1";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class AutoTranslatorPlugin : BaseUnityPlugin, IPluginEnvironment

public AutoTranslatorPlugin()
{
PluginPath = Path.Combine( Paths.PluginPath, "XUnity.AutoTranslator" );
ConfigPath = Paths.ConfigPath;
TranslationPath = Paths.BepInExRootPath;

Expand All @@ -35,8 +34,6 @@ public IniFile Preferences
}
}

public string PluginPath { get; }

public string ConfigPath { get; }

public string TranslationPath { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Version>4.7.0</Version>
<Version>4.7.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public AutoTranslatorPlugin()
// BepInEx 4.x paths cannot be trusted!
_dataPath = Path.Combine( Common.Constants.Paths.GameRoot, "BepInEx" );
_configPath = Path.Combine( _dataPath, "AutoTranslatorConfig.ini" );
//XuaLogger.Current = new BepInLogger();
}

public IniFile Preferences
Expand All @@ -34,8 +33,6 @@ public IniFile Preferences
}
}

public string PluginPath => _dataPath;

public string TranslationPath => _dataPath;

public string ConfigPath => _dataPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Version>4.7.0</Version>
<Version>4.7.1</Version>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\XUnity.AutoTranslator.Plugin.Core\XUnity.AutoTranslator.Plugin.Core.csproj" />
<ProjectReference Include="..\XUnity.Common\XUnity.Common.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ internal static class Settings
public static string OutputFile;
public static string SubstitutionFile;
public static string PreprocessorsFile;
//public static string PatternFile;
public static string TranslationDirectory;
public static int MaxCharactersPerTranslation;
public static bool EnableConsole;
Expand All @@ -77,7 +76,7 @@ internal static class Settings
public static string PreprocessorsFilePath;
public static string TranslationsPath;
public static string TexturesPath;
//public static string PatternFilePath;
public static string TranslatorsPath;
public static bool EnableIMGUI;
public static bool EnableUGUI;
public static bool EnableNGUI;
Expand Down Expand Up @@ -146,6 +145,10 @@ public static void Configure()
{
try
{
var fi = new FileInfo( typeof( TranslationManager ).Assembly.Location );
var di = fi.Directory;
TranslatorsPath = Path.Combine( di.FullName, TranslatorsFolder );

ApplicationName = Path.GetFileNameWithoutExtension( ApplicationInformation.StartupPath );

ServiceEndpoint = PluginEnvironment.Current.Preferences.GetOrDefault( "Service", "Endpoint", KnownTranslateEndpointNames.GoogleTranslate );
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.7.0";
public const string Version = "4.7.1";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public IniFile Preferences
return ( _file ?? ( _file = ReloadConfig() ) ); ;
}
}

public string PluginPath => _dataFolder;


public string TranslationPath => _dataFolder;

public string ConfigPath => _dataFolder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace XUnity.AutoTranslator.Plugin.Core.Endpoints
using System;

namespace XUnity.AutoTranslator.Plugin.Core.Endpoints
{
/// <summary>
/// Interface used in context of initializing a translator plugin.
Expand All @@ -8,8 +10,14 @@ public interface IInitializationContext
/// <summary>
/// Gets the directory where the configuration file and translations are stored.
/// </summary>
[Obsolete( "This property is not reliable.", true )]
string PluginDirectory { get; }

/// <summary>
/// Gets the directory where the translators are placed in.
/// </summary>
string TranslatorDirectory { get; }

/// <summary>
/// Gets or creates the specified setting.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ internal InitializationContext(
/// </summary>
public string DestinationLanguage { get; }

public string PluginDirectory => PluginEnvironment.Current.PluginPath;
[Obsolete("This property is not reliable.", true)]
public string PluginDirectory => Settings.TranslatorsPath;

public string TranslatorDirectory => Settings.TranslatorsPath;

public void DisableCertificateChecksFor( params string[] hosts )
{
Expand Down
5 changes: 0 additions & 5 deletions src/XUnity.AutoTranslator.Plugin.Core/IPluginEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ namespace XUnity.AutoTranslator.Plugin.Core
/// </summary>
public interface IPluginEnvironment
{
/// <summary>
/// Gets the path the plugin is located at.
/// </summary>
string PluginPath { get; }

/// <summary>
/// Gets or sets the path representing the root of the translations.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ private void LoadTranslationsInFile( string fullFileName, bool isSubstitutionFil
{
using( var stream = File.OpenRead( fullFileName ) )
{
// Perhaps use this instead???? https://github.com/icsharpcode/SharpZipLib/wiki/Unpack-a-zip-using-ZipInputStream
if( fullFileName.EndsWith( ".zip", StringComparison.OrdinalIgnoreCase ) )
{
using( var zipInputStream = new ZipInputStream( stream ) )
Expand All @@ -465,6 +464,9 @@ private void LoadTranslationsInFile( string fullFileName, bool isSubstitutionFil
}
else if( isSubstitutionFile || isPreprocessorFile )
{
var fi = new FileInfo( fullFileName );
Directory.CreateDirectory( fi.Directory.FullName );

using( var stream = File.Create( fullFileName ) )
{
stream.Write( new byte[] { 0xEF, 0xBB, 0xBF }, 0, 3 ); // UTF-8 BOM
Expand Down
3 changes: 1 addition & 2 deletions src/XUnity.AutoTranslator.Plugin.Core/TranslationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ public void CreateEndpoints( GameObject go, InitializationContext context )
{
if( Settings.FromLanguage != Settings.Language )
{
var pluginFolder = Path.Combine( PluginEnvironment.Current.PluginPath, Settings.TranslatorsFolder );
var dynamicTypes = AssemblyLoader.GetAllTypesOf<ITranslateEndpoint>( pluginFolder );
var dynamicTypes = AssemblyLoader.GetAllTypesOf<ITranslateEndpoint>( Settings.TranslatorsPath );

// add built-in endpoint
dynamicTypes.Add( typeof( PassthroughTranslateEndpoint ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
<PackageProjectUrl>https://github.com/bbepis/XUnity.AutoTranslator</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<DevelopmentDependency>True</DevelopmentDependency>
<TargetFramework>net35</TargetFramework>
<Version>4.7.0</Version>
<Version>4.7.1</Version>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<None Update="*.ps1" CopyToOutputDirectory="Always" Pack="true" PackagePath="tools" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\net35\XUnity.AutoTranslator.Plugin.Core.xml</DocumentationFile>
</PropertyGroup>
Expand Down Expand Up @@ -47,9 +52,9 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\XUnity.AutoTranslator.Plugin.ExtProtocol\XUnity.AutoTranslator.Plugin.ExtProtocol.csproj" />
<ProjectReference Include="..\XUnity.Common\XUnity.Common.csproj" />
<ProjectReference Include="..\XUnity.ResourceRedirector\XUnity.ResourceRedirector.csproj" />
<ProjectReference Include="..\XUnity.AutoTranslator.Plugin.ExtProtocol\XUnity.AutoTranslator.Plugin.ExtProtocol.csproj" PrivateAssets="All" />
<ProjectReference Include="..\XUnity.Common\XUnity.Common.csproj" PrivateAssets="All" />
<ProjectReference Include="..\XUnity.ResourceRedirector\XUnity.ResourceRedirector.csproj" PrivateAssets="All" />
</ItemGroup>

<Target Name="ILRepack" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
Expand Down
9 changes: 9 additions & 0 deletions src/XUnity.AutoTranslator.Plugin.Core/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
param($installPath, $toolsPath, $package, $project)
$asms = $package.AssemblyReferences | %{$_.Name}
foreach ($reference in $project.Object.References)
{
if ($asms -contains $reference.Name + ".dll")
{
$reference.CopyLocal = $false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
<PackageProjectUrl>https://github.com/bbepis/XUnity.AutoTranslator</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<DevelopmentDependency>True</DevelopmentDependency>
<TargetFramework>net35</TargetFramework>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
</PropertyGroup>

<ItemGroup>
<None Update="*.ps1" CopyToOutputDirectory="Always" Pack="true" PackagePath="tools" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>C:\Proj\Secret\XUnity.AutoTranslator\src\XUnity.AutoTranslator.Plugin.ExtProtocol\bin\Release\net35\XUnity.AutoTranslator.Plugin.ExtProtocol.xml</DocumentationFile>
</PropertyGroup>
Expand Down
9 changes: 9 additions & 0 deletions src/XUnity.AutoTranslator.Plugin.ExtProtocol/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
param($installPath, $toolsPath, $package, $project)
$asms = $package.AssemblyReferences | %{$_.Name}
foreach ($reference in $project.Object.References)
{
if ($asms -contains $reference.Name + ".dll")
{
$reference.CopyLocal = $false;
}
}
2 changes: 0 additions & 2 deletions src/XUnity.AutoTranslator.Plugin.IPA/AutoTranslatorPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public IniFile Preferences
}
}

public string PluginPath => _dataPath;

public string TranslationPath => _dataPath;

public string ConfigPath => _dataPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Version>4.7.0</Version>
<Version>4.7.1</Version>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\XUnity.AutoTranslator.Plugin.Core\XUnity.AutoTranslator.Plugin.Core.csproj" />
<ProjectReference Include="..\XUnity.Common\XUnity.Common.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ namespace XUnity.AutoTranslator.Plugin.UnityInjector
[PluginName( PluginData.Name ), PluginVersion( PluginData.Version )]
public class AutoTranslatorPlugin : PluginBase, IPluginEnvironment
{
public string PluginPath => DataPath;

public string TranslationPath => DataPath;

public string ConfigPath => DataPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Version>4.7.0</Version>
<Version>4.7.1</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -28,7 +28,7 @@
<ItemGroup>
<VersionNumber Include="$([System.Text.RegularExpressions.Regex]::Replace(&quot;%(Targets.Version)&quot;, &quot;^(.+?)(\.0+)$&quot;, &quot;$1&quot;))" />
</ItemGroup>
<Exec Command="if $(ConfigurationName) == Release (&#xD;&#xA; for %%f in (&quot;$(SolutionDir)dist\Translators\*&quot;) do XCOPY /Y /I &quot;%%f&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\Config\Translators\&quot;&#xD;&#xA; for %%f in (&quot;$(SolutionDir)dist\Translators\FullNET\*&quot;) do XCOPY /Y /I &quot;%%f&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\Config\Translators\FullNET\&quot;&#xD;&#xA; XCOPY /Y /I &quot;$(TargetDir)0Harmony.dll&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\&quot;&#xD;&#xA; XCOPY /Y /I &quot;$(TargetDir)XUnity.AutoTranslator.Plugin.Core.dll&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\&quot;&#xD;&#xA; XCOPY /Y /I &quot;$(TargetDir)XUnity.AutoTranslator.Plugin.ExtProtocol.dll&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\&quot;&#xD;&#xA; XCOPY /Y /I &quot;$(TargetDir)XUnity.Common.dll&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\&quot;&#xD;&#xA; XCOPY /Y /I &quot;$(TargetDir)XUnity.ResourceRedirector.dll&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\&quot;&#xD;&#xA; XCOPY /Y /I &quot;$(TargetDir)$(TargetName)$(TargetExt)&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\&quot;&#xD;&#xA; COPY /Y &quot;$(SolutionDir)README.md&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\Config\README (AutoTranslator).md&quot;&#xD;&#xA; powershell Compress-Archive -Path '$(SolutionDir)dist\UnityInjector\UnityInjector' -DestinationPath '$(SolutionDir)dist\UnityInjector\XUnity.AutoTranslator-UnityInjector-@(VersionNumber).zip' -Force)&#xD;&#xA;)" />
<Exec Command="if $(ConfigurationName) == Release (&#xD;&#xA; for %%f in (&quot;$(SolutionDir)dist\Translators\*&quot;) do XCOPY /Y /I &quot;%%f&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\Translators\&quot;&#xD;&#xA; for %%f in (&quot;$(SolutionDir)dist\Translators\FullNET\*&quot;) do XCOPY /Y /I &quot;%%f&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\Translators\FullNET\&quot;&#xD;&#xA; XCOPY /Y /I &quot;$(TargetDir)0Harmony.dll&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\&quot;&#xD;&#xA; XCOPY /Y /I &quot;$(TargetDir)XUnity.AutoTranslator.Plugin.Core.dll&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\&quot;&#xD;&#xA; XCOPY /Y /I &quot;$(TargetDir)XUnity.AutoTranslator.Plugin.ExtProtocol.dll&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\&quot;&#xD;&#xA; XCOPY /Y /I &quot;$(TargetDir)XUnity.Common.dll&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\&quot;&#xD;&#xA; XCOPY /Y /I &quot;$(TargetDir)XUnity.ResourceRedirector.dll&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\&quot;&#xD;&#xA; XCOPY /Y /I &quot;$(TargetDir)$(TargetName)$(TargetExt)&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\&quot;&#xD;&#xA; MKDIR &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\Config&quot;&#xD;&#xA; COPY /Y &quot;$(SolutionDir)README.md&quot; &quot;$(SolutionDir)dist\UnityInjector\UnityInjector\Config\README (AutoTranslator).md&quot;&#xD;&#xA; powershell Compress-Archive -Path '$(SolutionDir)dist\UnityInjector\UnityInjector' -DestinationPath '$(SolutionDir)dist\UnityInjector\XUnity.AutoTranslator-UnityInjector-@(VersionNumber).zip' -Force)&#xD;&#xA;)" />
</Target>

</Project>
Loading

0 comments on commit 8856468

Please sign in to comment.