|
@@ -21,7 +21,7 @@ namespace XUnity.AutoTranslator.Plugin.Core.Configuration
|
|
|
public static readonly float MaxTranslationsQueuedPerSecond = 5;
|
|
|
public static readonly int MaxSecondsAboveTranslationThreshold = 30;
|
|
|
public static readonly int TranslationQueueWatchWindow = 6;
|
|
|
-
|
|
|
+
|
|
|
// can be changed
|
|
|
public static string ServiceEndpoint;
|
|
|
public static string Language;
|
|
@@ -48,6 +48,8 @@ namespace XUnity.AutoTranslator.Plugin.Core.Configuration
|
|
|
public static string WatsonAPIUsername;
|
|
|
public static string WatsonAPIPassword;
|
|
|
public static int ForceSplitTextAfterCharacters;
|
|
|
+ public static bool EnableMigrations;
|
|
|
+ public static string MigrationsTag;
|
|
|
|
|
|
public static bool CopyToClipboard;
|
|
|
public static int MaxClipboardCopyCharacters;
|
|
@@ -95,19 +97,42 @@ namespace XUnity.AutoTranslator.Plugin.Core.Configuration
|
|
|
BaiduAppId = Config.Current.Preferences[ "Baidu" ][ "BaiduAppId" ].GetOrDefault( "" );
|
|
|
BaiduAppSecret = Config.Current.Preferences[ "Baidu" ][ "BaiduAppSecret" ].GetOrDefault( "" );
|
|
|
|
|
|
- YandexAPIKey = Config.Current.Preferences["Yandex"]["YandexAPIKey"].GetOrDefault("");
|
|
|
+ YandexAPIKey = Config.Current.Preferences[ "Yandex" ][ "YandexAPIKey" ].GetOrDefault( "" );
|
|
|
|
|
|
- WatsonAPIUrl = Config.Current.Preferences["Watson"]["WatsonAPIUrl"].GetOrDefault("");
|
|
|
- WatsonAPIUsername = Config.Current.Preferences["Watson"]["WatsonAPIUsername"].GetOrDefault("");
|
|
|
- WatsonAPIPassword = Config.Current.Preferences["Watson"]["WatsonAPIPassword"].GetOrDefault("");
|
|
|
+ WatsonAPIUrl = Config.Current.Preferences[ "Watson" ][ "WatsonAPIUrl" ].GetOrDefault( "" );
|
|
|
+ WatsonAPIUsername = Config.Current.Preferences[ "Watson" ][ "WatsonAPIUsername" ].GetOrDefault( "" );
|
|
|
+ WatsonAPIPassword = Config.Current.Preferences[ "Watson" ][ "WatsonAPIPassword" ].GetOrDefault( "" );
|
|
|
|
|
|
EnablePrintHierarchy = Config.Current.Preferences[ "Debug" ][ "EnablePrintHierarchy" ].GetOrDefault( false );
|
|
|
EnableConsole = Config.Current.Preferences[ "Debug" ][ "EnableConsole" ].GetOrDefault( false );
|
|
|
EnableDebugLogs = Config.Current.Preferences[ "Debug" ][ "EnableLog" ].GetOrDefault( false );
|
|
|
|
|
|
+ EnableMigrations = Config.Current.Preferences[ "Migrations" ][ "Enable" ].GetOrDefault( true );
|
|
|
+ MigrationsTag = Config.Current.Preferences[ "Migrations" ][ "Tag" ].GetOrDefault( string.Empty );
|
|
|
+
|
|
|
AutoTranslationsFilePath = Path.Combine( Config.Current.DataPath, OutputFile.Replace( "{lang}", Language ) );
|
|
|
|
|
|
+ if( EnableMigrations )
|
|
|
+ {
|
|
|
+ Migrate();
|
|
|
+ }
|
|
|
+
|
|
|
+ // update tag
|
|
|
+ Config.Current.Preferences[ "Migrations" ][ "Tag" ].Value = PluginData.Version;
|
|
|
+
|
|
|
Config.Current.SaveConfig();
|
|
|
}
|
|
|
+
|
|
|
+ private static void Migrate()
|
|
|
+ {
|
|
|
+ var currentTag = MigrationsTag;
|
|
|
+ var newTag = PluginData.Version;
|
|
|
+
|
|
|
+ // migrate from unknown version to known version. Reset to google translate
|
|
|
+ if( string.IsNullOrEmpty( currentTag ) )
|
|
|
+ {
|
|
|
+ Config.Current.Preferences[ "Service" ][ "Endpoint" ].Value = KnownEndpointNames.GoogleTranslate;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|