Browse Source

finalized release

Scrublord1336 6 years ago
parent
commit
f08cafc7cf

+ 25 - 7
src/XUnity.AutoTranslator.Plugin.Core/AutoTranslationPlugin.cs

@@ -403,6 +403,14 @@ namespace XUnity.AutoTranslator.Plugin.Core
          }
          }
       }
       }
 
 
+      private void QueueNewTranslationForDisk( string key, string value )
+      {
+         lock( _writeToFileSync )
+         {
+            _newTranslations[ key ] = value;
+         }
+      }
+
       private bool TryGetTranslation( TranslationKey key, out string value )
       private bool TryGetTranslation( TranslationKey key, out string value )
       {
       {
          return _translations.TryGetValue( key.GetDictionaryLookupKey(), out value );
          return _translations.TryGetValue( key.GetDictionaryLookupKey(), out value );
@@ -875,7 +883,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
                   _kickedOff.Add( key );
                   _kickedOff.Add( key );
 
 
                   if( !job.AnyComponentsStillHasOriginalUntranslatedTextOrContextual() ) continue;
                   if( !job.AnyComponentsStillHasOriginalUntranslatedTextOrContextual() ) continue;
-                  
+
                   batch.Add( job );
                   batch.Add( job );
                   _ongoingJobs[ key ] = job;
                   _ongoingJobs[ key ] = job;
                }
                }
@@ -1102,17 +1110,27 @@ namespace XUnity.AutoTranslator.Plugin.Core
                   {
                   {
                      try
                      try
                      {
                      {
+
                         var text = context.Component.GetText().TrimIfConfigured();
                         var text = context.Component.GetText().TrimIfConfigured();
                         var result = context.Result;
                         var result = context.Result;
+                        Dictionary<string, string> translations = new Dictionary<string, string>();
+                        var translatedText = TranslateOrQueueWebJobImmediateByParserResult( null, result, false );
 
 
-                        if( text == result.OriginalText )
+                        if( !string.IsNullOrEmpty( translatedText ) )
                         {
                         {
-                           Dictionary<string, string> translations = new Dictionary<string, string>();
-                           var translatedText = TranslateOrQueueWebJobImmediateByParserResult( null, result, false );
-                           if( translatedText != null )
+                           if( !_translations.ContainsKey( context.Result.OriginalText ) )
+                           {
+                              AddTranslation( context.Result.OriginalText, translatedText );
+                              QueueNewTranslationForDisk( context.Result.OriginalText, translatedText );
+                           }
+
+                           if( text == result.OriginalText )
                            {
                            {
-                              var info = context.Component.GetTranslationInfo( false );
-                              SetTranslatedText( context.Component, translatedText, info );
+                              if( translatedText != null )
+                              {
+                                 var info = context.Component.GetTranslationInfo( false );
+                                 SetTranslatedText( context.Component, translatedText, info );
+                              }
                            }
                            }
                         }
                         }
                      }
                      }

+ 0 - 2
src/XUnity.AutoTranslator.Plugin.Core/Constants/Types.cs

@@ -32,8 +32,6 @@ namespace XUnity.AutoTranslator.Plugin.Core.Constants
 
 
       public static readonly Type AdvScenarioLabelData = FindType( "Utage.AdvScenarioLabelData" );
       public static readonly Type AdvScenarioLabelData = FindType( "Utage.AdvScenarioLabelData" );
 
 
-      public static readonly Type AdvUguiSelection = FindType( "Utage.AdvUguiSelection" );
-
       private static Type FindType( string name )
       private static Type FindType( string name )
       {
       {
          return AppDomain.CurrentDomain.GetAssemblies()
          return AppDomain.CurrentDomain.GetAssemblies()

+ 2 - 12
src/XUnity.AutoTranslator.Plugin.Core/Extensions/ComponentExtensions.cs

@@ -18,12 +18,7 @@ namespace XUnity.AutoTranslator.Plugin.Core.Extensions
          string text = null;
          string text = null;
          var type = ui.GetType();
          var type = ui.GetType();
 
 
-         if( type == Constants.Types.UguiNovelText && ( (Component)ui ).gameObject.GetFirstComponentInSelfOrAncestor( Constants.Types.AdvUguiSelection ) != null )
-         {
-            // these texts are handled by AdvCommand, unless it is a selection
-            text = ( (Text)ui ).text;
-         }
-         else if( ui is Text )
+         if( ui is Text )
          {
          {
             text = ( (Text)ui ).text;
             text = ( (Text)ui ).text;
          }
          }
@@ -46,12 +41,7 @@ namespace XUnity.AutoTranslator.Plugin.Core.Extensions
 
 
          var type = ui.GetType();
          var type = ui.GetType();
 
 
-         if( type == Constants.Types.UguiNovelText && ( ( Component ) ui ).gameObject.GetFirstComponentInSelfOrAncestor( Constants.Types.AdvUguiSelection ) != null )
-         {
-            // these texts are handled by AdvCommand, unless it is a selection
-            ( (Text)ui ).text = text;
-         }
-         else if( ui is Text )
+         if( ui is Text )
          {
          {
             ( (Text)ui ).text = text;
             ( (Text)ui ).text = text;
          }
          }