瀏覽代碼

some renaming

Scrublord1336 6 年之前
父節點
當前提交
c1cc8180e1

+ 23 - 23
src/XUnity.AutoTranslator.Plugin.Core/AutoTranslationPlugin.cs

@@ -229,7 +229,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
          }
       }
 
-      private TranslationJob GetOrCreateTranslationJobFor( TranslationKeys key )
+      private TranslationJob GetOrCreateTranslationJobFor( TranslationKey key )
       {
          if( _unstartedJobs.TryGetValue( key.GetDictionaryLookupKey(), out TranslationJob job ) )
          {
@@ -238,7 +238,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
 
          foreach( var completedJob in _completedJobs )
          {
-            if( completedJob.Keys.GetDictionaryLookupKey() == key.GetDictionaryLookupKey() )
+            if( completedJob.Key.GetDictionaryLookupKey() == key.GetDictionaryLookupKey() )
             {
                return completedJob;
             }
@@ -321,32 +321,32 @@ namespace XUnity.AutoTranslator.Plugin.Core
          _translatedTexts.Add( value );
       }
 
-      private void AddTranslation( TranslationKeys key, string value )
+      private void AddTranslation( TranslationKey key, string value )
       {
          _translations[ key.GetDictionaryLookupKey() ] = value;
          _translatedTexts.Add( value );
       }
 
-      private void QueueNewUntranslatedForClipboard( TranslationKeys key )
+      private void QueueNewUntranslatedForClipboard( TranslationKey key )
       {
          if( Settings.CopyToClipboard )
          {
-            if( !_textsToCopyToClipboard.Contains( key.RelevantKey ) )
+            if( !_textsToCopyToClipboard.Contains( key.RelevantText ) )
             {
-               _textsToCopyToClipboard.Add( key.RelevantKey );
-               _textsToCopyToClipboardOrdered.Add( key.RelevantKey );
+               _textsToCopyToClipboard.Add( key.RelevantText );
+               _textsToCopyToClipboardOrdered.Add( key.RelevantText );
 
                _clipboardUpdated = Time.realtimeSinceStartup;
             }
          }
       }
 
-      private void QueueNewUntranslatedForDisk( TranslationKeys key )
+      private void QueueNewUntranslatedForDisk( TranslationKey key )
       {
          _newUntranslated.Add( key.GetDictionaryLookupKey() );
       }
 
-      private void QueueNewTranslationForDisk( TranslationKeys key, string value )
+      private void QueueNewTranslationForDisk( TranslationKey key, string value )
       {
          lock( _writeToFileSync )
          {
@@ -354,7 +354,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
          }
       }
 
-      private bool TryGetTranslation( TranslationKeys key, out string value )
+      private bool TryGetTranslation( TranslationKey key, out string value )
       {
          return _translations.TryGetValue( key.GetDictionaryLookupKey(), out value );
       }
@@ -384,7 +384,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
          }
       }
 
-      private void SetTranslatedText( object ui, string translatedText, TranslationKeys key, TranslationInfo info )
+      private void SetTranslatedText( object ui, string translatedText, TranslationKey key, TranslationInfo info )
       {
          var untemplatedTranslatedText = key.Untemplate( translatedText );
 
@@ -524,7 +524,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
          {
             info?.Reset( text );
 
-            var textKey = new TranslationKeys( text, !supportsStabilization );
+            var textKey = new TranslationKey( text, !supportsStabilization );
 
             // if we already have translation loaded in our _translatios dictionary, simply load it and set text
             string translation;
@@ -572,7 +572,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
 
                               if( !string.IsNullOrEmpty( stabilizedText ) && IsTranslatable( stabilizedText ) )
                               {
-                                 var stabilizedTextKey = new TranslationKeys( stabilizedText, false );
+                                 var stabilizedTextKey = new TranslationKey( stabilizedText, false );
 
                                  QueueNewUntranslatedForClipboard( stabilizedTextKey );
 
@@ -773,7 +773,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
                // lets see if the text should still be translated before kicking anything off
                if( !job.AnyComponentsStillHasOriginalUntranslatedText() ) continue;
 
-               StartCoroutine( _endpoint.Translate( job.Keys.GetDictionaryLookupKey(), Settings.FromLanguage, Settings.Language, translatedText => OnSingleTranslationCompleted( job, translatedText ),
+               StartCoroutine( _endpoint.Translate( job.Key.GetDictionaryLookupKey(), Settings.FromLanguage, Settings.Language, translatedText => OnSingleTranslationCompleted( job, translatedText ),
                () => OnTranslationFailed() ) );
             }
          }
@@ -814,9 +814,9 @@ namespace XUnity.AutoTranslator.Plugin.Core
                   {
                      translatedText = translatedText.SplitToLines( Settings.ForceSplitTextAfterCharacters, '\n', ' ', ' ' );
                   }
-                  job.TranslatedText = job.Keys.RepairTemplate( translatedText );
+                  job.TranslatedText = job.Key.RepairTemplate( translatedText );
 
-                  QueueNewTranslationForDisk( job.Keys, translatedText );
+                  QueueNewTranslationForDisk( job.Key, translatedText );
                   _completedJobs.Add( job );
                }
             }
@@ -827,7 +827,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
             _batchLogicHasFailed = true;
             foreach( var tracker in batch.Trackers )
             {
-               var key = tracker.Job.Keys.GetDictionaryLookupKey();
+               var key = tracker.Job.Key.GetDictionaryLookupKey();
                if( !_unstartedJobs.ContainsKey( key ) )
                {
                   _unstartedJobs[ key ] = tracker.Job;
@@ -859,9 +859,9 @@ namespace XUnity.AutoTranslator.Plugin.Core
             {
                translatedText = translatedText.SplitToLines( Settings.ForceSplitTextAfterCharacters, '\n', ' ', ' ' );
             }
-            job.TranslatedText = job.Keys.RepairTemplate( translatedText );
+            job.TranslatedText = job.Key.RepairTemplate( translatedText );
 
-            QueueNewTranslationForDisk( job.Keys, translatedText );
+            QueueNewTranslationForDisk( job.Key, translatedText );
             _completedJobs.Add( job );
          }
       }
@@ -904,14 +904,14 @@ namespace XUnity.AutoTranslator.Plugin.Core
                {
                   // update the original text, but only if it has not been chaanged already for some reason (could be other translator plugin or game itself)
                   var text = component.GetText().Trim();
-                  if( text == job.Keys.OriginalText )
+                  if( text == job.Key.OriginalText )
                   {
                      var info = component.GetTranslationInfo( false );
-                     SetTranslatedText( component, job.TranslatedText, job.Keys, info );
+                     SetTranslatedText( component, job.TranslatedText, job.Key, info );
                   }
                }
 
-               AddTranslation( job.Keys, job.TranslatedText );
+               AddTranslation( job.Key, job.TranslatedText );
             }
          }
       }
@@ -925,7 +925,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
             var info = kvp.Value as TranslationInfo;
             if( info != null && !string.IsNullOrEmpty( info.OriginalText ) )
             {
-               var key = new TranslationKeys( info.OriginalText, false );
+               var key = new TranslationKey( info.OriginalText, false );
                if( TryGetTranslation( key, out string translatedText ) && !string.IsNullOrEmpty( translatedText ) )
                {
                   SetTranslatedText( kvp.Key, translatedText, key, info );

+ 1 - 1
src/XUnity.AutoTranslator.Plugin.Core/Batching/TranslationBatch.cs

@@ -56,7 +56,7 @@ namespace XUnity.AutoTranslator.Plugin.Core.Batching
          for( int i = 0 ; i < Trackers.Count ; i++ )
          {
             var tracker = Trackers[ i ];
-            builder.Append( tracker.Job.Keys.GetDictionaryLookupKey() );
+            builder.Append( tracker.Job.Key.GetDictionaryLookupKey() );
 
             if( !( i == Trackers.Count - 1 ) )
             {

+ 1 - 1
src/XUnity.AutoTranslator.Plugin.Core/Batching/TranslationLineTracker.cs

@@ -7,7 +7,7 @@ namespace XUnity.AutoTranslator.Plugin.Core.Batching
       public TranslationLineTracker( TranslationJob job )
       {
          Job = job;
-         LinesCount = job.Keys.GetDictionaryLookupKey().Count( c => c == '\n' ) + 1;
+         LinesCount = job.Key.GetDictionaryLookupKey().Count( c => c == '\n' ) + 1;
       }
 
       public string RawTranslatedText { get; set; }

+ 4 - 4
src/XUnity.AutoTranslator.Plugin.Core/TranslationJob.cs

@@ -10,16 +10,16 @@ namespace XUnity.AutoTranslator.Plugin.Core
 {
    public class TranslationJob
    {
-      public TranslationJob( TranslationKeys key )
+      public TranslationJob( TranslationKey key )
       {
-         Keys = key;
+         Key = key;
 
          Components = new List<object>();
       }
 
       public List<object> Components { get; private set; }
       
-      public TranslationKeys Keys { get; private set; }
+      public TranslationKey Key { get; private set; }
 
       public string TranslatedText { get; set; }
 
@@ -30,7 +30,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
          foreach( var component in Components )
          {
             var text = component.GetText().Trim();
-            if( text == Keys.OriginalText )
+            if( text == Key.OriginalText )
             {
                return true;
             }

+ 15 - 15
src/XUnity.AutoTranslator.Plugin.Core/TranslationKeys.cs → src/XUnity.AutoTranslator.Plugin.Core/TranslationKey.cs

@@ -7,51 +7,51 @@ using XUnity.AutoTranslator.Plugin.Core.Extensions;
 
 namespace XUnity.AutoTranslator.Plugin.Core
 {
-   public struct TranslationKeys
+   public struct TranslationKey
    {
-      public TranslationKeys( string key, bool templatizeByNumbers )
+      public TranslationKey( string key, bool templatizeByNumbers )
       {
          OriginalText = key;
 
          if( Settings.IgnoreWhitespaceInDialogue && key.Length > Settings.MinDialogueChars )
          {
-            RelevantKey = key.RemoveWhitespace();
+            RelevantText = key.RemoveWhitespace();
          }
          else
          {
-            RelevantKey = key;
+            RelevantText = key;
          }
 
          if( templatizeByNumbers )
          {
-            TemplatedKey = RelevantKey.TemplatizeByNumbers();
+            TemplatedText = RelevantText.TemplatizeByNumbers();
          }
          else
          {
-            TemplatedKey = null;
+            TemplatedText = null;
          }
       }
 
-      public TemplatedString TemplatedKey { get; }
+      public TemplatedString TemplatedText { get; }
 
-      public string RelevantKey { get; }
+      public string RelevantText { get; }
 
       public string OriginalText { get; set; }
 
       public string GetDictionaryLookupKey()
       {
-         if( TemplatedKey != null )
+         if( TemplatedText != null )
          {
-            return TemplatedKey.Template;
+            return TemplatedText.Template;
          }
-         return RelevantKey;
+         return RelevantText;
       }
 
       public string Untemplate( string text )
       {
-         if( TemplatedKey != null )
+         if( TemplatedText != null )
          {
-            return TemplatedKey.Untemplate( text );
+            return TemplatedText.Untemplate( text );
          }
 
          return text;
@@ -59,9 +59,9 @@ namespace XUnity.AutoTranslator.Plugin.Core
 
       public string RepairTemplate( string text )
       {
-         if( TemplatedKey != null )
+         if( TemplatedText != null )
          {
-            return TemplatedKey.RepairTemplate( text );
+            return TemplatedText.RepairTemplate( text );
          }
 
          return text;