Browse Source

Add support for the brazilian portuguese language code (#2792)

* Add support for the brazilian portuguese language code

* Fix error applet message
gdkchan 4 năm trước cách đây
mục cha
commit
a7a40a77f2

+ 6 - 6
Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs

@@ -94,13 +94,14 @@ namespace Ryujinx.HLE.HOS.Applets.Error
                 SystemLanguage.LatinAmericanSpanish => "es-419",
                 SystemLanguage.LatinAmericanSpanish => "es-419",
                 SystemLanguage.SimplifiedChinese    => "zh-Hans",
                 SystemLanguage.SimplifiedChinese    => "zh-Hans",
                 SystemLanguage.TraditionalChinese   => "zh-Hant",
                 SystemLanguage.TraditionalChinese   => "zh-Hant",
+                SystemLanguage.BrazilianPortuguese  => "pt-BR",
                 _                                   => "en-US"
                 _                                   => "en-US"
             };
             };
         }
         }
 
 
-        public string CleanText(string value)
+        private static string CleanText(string value)
         {
         {
-            return Regex.Replace(Encoding.Unicode.GetString(Encoding.UTF8.GetBytes(value)), @"[^\u0009\u000A\u000D\u0020-\u007E]", "");
+            return Regex.Replace(value, @"[^\u0000\u0009\u000A\u000D\u0020-\uFFFF]..", "").Replace("\0", "");
         }
         }
 
 
         private string GetMessageText(uint module, uint description, string key)
         private string GetMessageText(uint module, uint description, string key)
@@ -112,13 +113,12 @@ namespace Ryujinx.HLE.HOS.Applets.Error
                 Nca         nca          = new Nca(_horizon.Device.FileSystem.KeySet, ncaFileStream);
                 Nca         nca          = new Nca(_horizon.Device.FileSystem.KeySet, ncaFileStream);
                 IFileSystem romfs        = nca.OpenFileSystem(NcaSectionType.Data, _horizon.FsIntegrityCheckLevel);
                 IFileSystem romfs        = nca.OpenFileSystem(NcaSectionType.Data, _horizon.FsIntegrityCheckLevel);
                 string      languageCode = SystemLanguageToLanguageKey(_horizon.State.DesiredSystemLanguage);
                 string      languageCode = SystemLanguageToLanguageKey(_horizon.State.DesiredSystemLanguage);
-                string      filePath     = "/" + Path.Combine(module.ToString(), $"{description:0000}", $"{languageCode}_{key}").Replace(@"\", "/");
+                string      filePath     = $"/{module}/{description:0000}/{languageCode}_{key}";
 
 
                 if (romfs.FileExists(filePath))
                 if (romfs.FileExists(filePath))
                 {
                 {
                     romfs.OpenFile(out IFile binaryFile, filePath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
                     romfs.OpenFile(out IFile binaryFile, filePath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
-
-                    StreamReader reader = new StreamReader(binaryFile.AsStream());
+                    StreamReader reader = new StreamReader(binaryFile.AsStream(), Encoding.Unicode);
 
 
                     return CleanText(reader.ReadToEnd());
                     return CleanText(reader.ReadToEnd());
                 }
                 }
@@ -149,7 +149,7 @@ namespace Ryujinx.HLE.HOS.Applets.Error
             }
             }
 
 
             string message = GetMessageText(module, description, "DlgMsg");
             string message = GetMessageText(module, description, "DlgMsg");
-        
+
             if (message == "")
             if (message == "")
             {
             {
                 message = "An error has occured.\n\n"
                 message = "An error has occured.\n\n"

+ 2 - 2
Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs

@@ -151,7 +151,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
             int  supportedLanguages  = (int)context.Device.Application.ControlData.Value.SupportedLanguages;
             int  supportedLanguages  = (int)context.Device.Application.ControlData.Value.SupportedLanguages;
             int  firstSupported      = BitOperations.TrailingZeroCount(supportedLanguages);
             int  firstSupported      = BitOperations.TrailingZeroCount(supportedLanguages);
 
 
-            if (firstSupported > (int)SystemState.TitleLanguage.Chinese)
+            if (firstSupported > (int)SystemState.TitleLanguage.BrazilianPortuguese)
             {
             {
                 Logger.Warning?.Print(LogClass.ServiceAm, "Application has zero supported languages");
                 Logger.Warning?.Print(LogClass.ServiceAm, "Application has zero supported languages");
 
 
@@ -578,7 +578,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
         {
         {
             // NOTE: IStorage are pushed in the channel with IApplicationAccessor PushToFriendInvitationStorageChannel
             // NOTE: IStorage are pushed in the channel with IApplicationAccessor PushToFriendInvitationStorageChannel
             //       If _friendInvitationStorageChannelEvent is signaled, the event is cleared.
             //       If _friendInvitationStorageChannelEvent is signaled, the event is cleared.
-            //       If an IStorage is available, returns it with ResultCode.Success. 
+            //       If an IStorage is available, returns it with ResultCode.Success.
             //       If not, just returns ResultCode.NotAvailable. Since we don't support friend feature for now, it's fine to do the same.
             //       If not, just returns ResultCode.NotAvailable. Since we don't support friend feature for now, it's fine to do the same.
 
 
             Logger.Stub?.PrintStub(LogClass.ServiceAm);
             Logger.Stub?.PrintStub(LogClass.ServiceAm);

+ 2 - 1
Ryujinx.HLE/HOS/SystemState/SystemLanguage.cs

@@ -18,6 +18,7 @@ namespace Ryujinx.HLE.HOS.SystemState
         CanadianFrench,
         CanadianFrench,
         LatinAmericanSpanish,
         LatinAmericanSpanish,
         SimplifiedChinese,
         SimplifiedChinese,
-        TraditionalChinese
+        TraditionalChinese,
+        BrazilianPortuguese
     }
     }
 }
 }

+ 2 - 1
Ryujinx.HLE/HOS/SystemState/SystemStateMgr.cs

@@ -22,7 +22,8 @@ namespace Ryujinx.HLE.HOS.SystemState
             "fr-CA",
             "fr-CA",
             "es-419",
             "es-419",
             "zh-Hans",
             "zh-Hans",
-            "zh-Hant"
+            "zh-Hant",
+            "pt-BR"
         };
         };
 
 
         internal long DesiredKeyboardLayout { get; private set; }
         internal long DesiredKeyboardLayout { get; private set; }

+ 2 - 1
Ryujinx.HLE/HOS/SystemState/TitleLanguage.cs

@@ -16,6 +16,7 @@
         Russian,
         Russian,
         Korean,
         Korean,
         Taiwanese,
         Taiwanese,
-        Chinese
+        Chinese,
+        BrazilianPortuguese
     }
     }
 }
 }

+ 2 - 1
Ryujinx/Configuration/System/Language.cs

@@ -18,6 +18,7 @@
         CanadianFrench,
         CanadianFrench,
         LatinAmericanSpanish,
         LatinAmericanSpanish,
         SimplifiedChinese,
         SimplifiedChinese,
-        TraditionalChinese
+        TraditionalChinese,
+        BrazilianPortuguese
     }
     }
 }
 }

+ 1 - 0
Ryujinx/Ui/Windows/SettingsWindow.glade

@@ -1266,6 +1266,7 @@
                                           <item id="Spanish" translatable="yes">Spanish</item>
                                           <item id="Spanish" translatable="yes">Spanish</item>
                                           <item id="Taiwanese" translatable="yes">Taiwanese</item>
                                           <item id="Taiwanese" translatable="yes">Taiwanese</item>
                                           <item id="TraditionalChinese" translatable="yes">Traditional Chinese</item>
                                           <item id="TraditionalChinese" translatable="yes">Traditional Chinese</item>
+                                          <item id="BrazilianPortuguese" translatable="yes">Brazilian Portuguese</item>
                                         </items>
                                         </items>
                                       </object>
                                       </object>
                                       <packing>
                                       <packing>