liyijie 1 год назад
Родитель
Сommit
ff1ff6e107

+ 30 - 6
PDF Office/Helper/ChatGTPAIHelper.cs

@@ -69,7 +69,7 @@ namespace PDF_Master.Helper
         /// 翻译指定内容,可以指定语言
         /// </summary>
         /// <param name="content"></param>
-        /// <param name="language">1=中文 2=英文 3=法语 4=汉语</param>
+        /// <param name="filename"></param>
         /// <returns></returns>
         public async static Task<string> fileKeyTranslate(string content, string filename)
         {
@@ -510,7 +510,10 @@ namespace PDF_Master.Helper
             return list;
         }
 
-        public static string Code = "";
+        /// <summary>
+        /// chatGPT错误码
+        /// </summary>
+        public static string ChatGPTCode = "";
 
         /// <summary>
         /// 从接口获取信息,获取message对应value值
@@ -535,8 +538,8 @@ namespace PDF_Master.Helper
                     App.mainWindowViewModel.Value = 8;
                     string unicode = "";
                     // 遍历字典对象输出键值对
-                    Code = jobject["code"].ToObject<string>().ToLower();
-                    if (Code == "200")
+                    ChatGPTCode = jobject["code"].ToObject<string>().ToLower();
+                    if (ChatGPTCode == "200")
                     {
                         unicode = jobject["data"][key].ToObject<string>().ToLower();
                     }
@@ -556,9 +559,9 @@ namespace PDF_Master.Helper
                 }
                 if (statusCode == 401)
                 {
-                    Code= "401";
+                    ChatGPTCode= "401";
                 }
-                else Code = "300";
+                else ChatGPTCode = "300";
                 clossProcess();
                 return null;
             }
@@ -733,6 +736,27 @@ namespace PDF_Master.Helper
             }
         }
         #endregion
+
+        #region 错误码
+
+        public static string GetBaiduTranslationCode(string code) {
+            
+            if (!String.IsNullOrEmpty(App.HomePageLoader.GetString("BaiduTranslation" + code))) {
+                return App.HomePageLoader.GetString("BaiduTranslation" + code);
+            }
+            return code;
+        }
+
+        public static string GetChatGPTCode(string code)
+        {
+            if (!String.IsNullOrEmpty(App.HomePageLoader.GetString("ChatGTP" + code)))
+            {
+                return App.HomePageLoader.GetString("ChatGTP" + code);
+            }
+            return code;
+        }
+
+        #endregion
     }
 }
 

+ 4 - 0
PDF Office/MultilingualResources/PDF Office.en.xlf

@@ -1126,6 +1126,10 @@ per month.</target>
           <source>Missing parameters</source>
           <target state="new">Missing parameters</target>
         </trans-unit>
+        <trans-unit id="ChatGTPLimit150" translate="yes" xml:space="preserve">
+          <source>Limited to 150 characters per session, 5 times per month</source>
+          <target state="new">Limited to 150 characters per session, 5 times per month</target>
+        </trans-unit>
       </group>
     </body>
   </file>

+ 4 - 0
PDF Office/MultilingualResources/PDF Office.zh-Hans.xlf

@@ -1126,6 +1126,10 @@ per month.</target>
           <source>Missing parameters</source>
           <target state="new">Missing parameters</target>
         </trans-unit>
+        <trans-unit id="ChatGTPLimit150" translate="yes" xml:space="preserve">
+          <source>Limited to 150 characters per session, 5 times per month</source>
+          <target state="new">Limited to 150 characters per session, 5 times per month</target>
+        </trans-unit>
       </group>
     </body>
   </file>

+ 4 - 0
PDF Office/MultilingualResources/PDF Office.zh-Hant.xlf

@@ -1126,6 +1126,10 @@ per month.</target>
           <source>Missing parameters</source>
           <target state="new">Missing parameters</target>
         </trans-unit>
+        <trans-unit id="ChatGTPLimit150" translate="yes" xml:space="preserve">
+          <source>Limited to 150 characters per session, 5 times per month</source>
+          <target state="new">Limited to 150 characters per session, 5 times per month</target>
+        </trans-unit>
       </group>
     </body>
   </file>

+ 9 - 0
PDF Office/Strings/HomePage/HomePage.Designer.cs

@@ -692,6 +692,15 @@ namespace PDF_Master.Strings.HomePage {
             }
         }
         
+        /// <summary>
+        ///   查找类似 Limited to 150 characters per session, 5 times per month 的本地化字符串。
+        /// </summary>
+        public static string ChatGTPLimit150 {
+            get {
+                return ResourceManager.GetString("ChatGTPLimit150", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   查找类似 Next 的本地化字符串。
         /// </summary>

+ 3 - 0
PDF Office/Strings/HomePage/HomePage.resx

@@ -329,6 +329,9 @@ per month.</value>
   <data name="ChatGTPAI_TextBoxWatermark" xml:space="preserve">
     <value>Please enter text content here...</value>
   </data>
+  <data name="ChatGTPLimit150" xml:space="preserve">
+    <value>Limited to 150 characters per session, 5 times per month</value>
+  </data>
   <data name="GuidContentP1" xml:space="preserve">
     <value>PDF Master Beta Invites You to Enjoy All Advanced Features!
 

+ 2 - 1
PDF Office/ViewModels/Dialog/ChatGPTAIDialogs/DocumentaryTranslationDialogViewModel.cs

@@ -320,8 +320,9 @@ namespace PDF_Master.ViewModels.Dialog.ChatGPTAIDialogs
                 else
                 {
                     //newfile code
+                    if (newfile == "-1") { return; }
                     AlertsMessage alertsMessage = new AlertsMessage();
-                    alertsMessage.ShowDialog("", newfile, App.ServiceLoader.GetString("Text_ok"));
+                    alertsMessage.ShowDialog("",  ChatGTPAIHelper.GetBaiduTranslationCode(newfile), App.ServiceLoader.GetString("Text_ok"));
                 }
             }
 

+ 1 - 1
PDF Office/ViewModels/Dialog/ChatGPTAIDialogs/SelectedTranslationDialogViewModel.cs

@@ -295,7 +295,7 @@ namespace PDF_Master.ViewModels.Dialog.ChatGPTAIDialogs
                 if (ConverterPreview.Text.Length > 150)
                 {
 
-                    ErrorTipText = "Limit 150 characters at a time";
+                    ErrorTipText = App.HomePageLoader.GetString("ChatGTPLimit150"); ;
                     ErrorVisible = Visibility.Visible;
                 }
                 else {

+ 4 - 4
PDF Office/ViewModels/HomePanel/ChatGPTAI/ChatGPTAIErrorCorrectionContentViewModel.cs

@@ -145,7 +145,7 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
             }
         }
 
-        private string errorTipText = "Limit 150 characters at a time";
+        private string errorTipText = App.HomePageLoader.GetString("ChatGTPLimit150");
 
         public string ErrorTipText
         {
@@ -203,7 +203,7 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
                 ErrorCorrectionText = "";
                 if (ConverterPreview.Text.Length > 150)
                 {
-                    ErrorTipText = "Limit 150 characters at a time";
+                    ErrorTipText = App.HomePageLoader.GetString("ChatGTPLimit150");
                     ErrorVisible = Visibility.Visible;
                 }
                 else
@@ -248,10 +248,10 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
             {
                 ErrorCorrectionText = await ChatGTPAIHelper.Correction(InputText);
             });
-            if (ChatGTPAIHelper.Code != "200")
+            if (ChatGTPAIHelper.ChatGPTCode != "200")
             {
                 //错误提示文案,与错误提示框
-                ErrorTipText = ChatGTPAIHelper.Code;
+                ErrorTipText = ChatGTPAIHelper.GetChatGPTCode(ChatGTPAIHelper.ChatGPTCode);
                 ErrorVisible = Visibility.Visible;
             }
         }

+ 4 - 4
PDF Office/ViewModels/HomePanel/ChatGPTAI/ChatGPTAIRewritingContentViewModel.cs

@@ -146,7 +146,7 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
             }
         }
 
-        private string errorTipText;
+        private string errorTipText= App.HomePageLoader.GetString("ChatGTPLimit150");
 
         public string ErrorTipText
         {
@@ -204,7 +204,7 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
                 RewriteText = "";
                 if (ConverterPreview.Text.Length > 150)
                 {
-                    ErrorTipText = "Limit 150 characters at a time";
+                    ErrorTipText = App.HomePageLoader.GetString("ChatGTPLimit150"); ;
                     ErrorVisible = Visibility.Visible;
                 }
                 else
@@ -250,10 +250,10 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
             {
                 RewriteText = await ChatGTPAIHelper.Rewrite(InputText);
             });
-            if (ChatGTPAIHelper.Code != "200")
+            if (ChatGTPAIHelper.ChatGPTCode != "200")
             {
                 //错误码文案,报错样式
-                ErrorTipText = ChatGTPAIHelper.Code;
+                ErrorTipText = ChatGTPAIHelper.GetChatGPTCode(ChatGTPAIHelper.ChatGPTCode); 
                 ErrorVisible = Visibility.Visible;
             }
         }

+ 2 - 1
PDF Office/ViewModels/HomePanel/ChatGPTAI/ChatGPTAITranslationContentViewModel.cs

@@ -325,7 +325,8 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
                     }
                 }
                 //newfile code
-                ErrorTipText = newfile;
+                if (newfile == "-1") { return; }
+                ErrorTipText = ChatGTPAIHelper.GetBaiduTranslationCode(newfile);
                 ErrorTipVisible = Visibility.Visible;
             }
         }