SDL: N3DS: Fix locale name and early return. (4a79f)

From 4a79fe44fff8459fb516dbd208623b1a6ae791cf Mon Sep 17 00:00:00 2001
From: Pierre Wendling <[EMAIL REDACTED]>
Date: Tue, 19 Mar 2024 23:39:22 +0100
Subject: [PATCH] N3DS: Fix locale name and early return.

- The name for simplified Chinese should be `zh_CN`.
- Ensure `cfguExit` is called even if `CFGU_GetSystemLanguage` failed.

(cherry picked from commit 390fff4ae0f79719a4d45b2ed44d0b3a22838337)
---
 src/locale/n3ds/SDL_syslocale.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/locale/n3ds/SDL_syslocale.c b/src/locale/n3ds/SDL_syslocale.c
index 0f6f03745a61e..1573f28bc03a0 100644
--- a/src/locale/n3ds/SDL_syslocale.c
+++ b/src/locale/n3ds/SDL_syslocale.c
@@ -33,7 +33,7 @@ void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
 {
     /* The 3DS only supports these 12 languages, only one can be active at a time */
     static const char AVAILABLE_LOCALES[][6] = { "ja_JP", "en_US", "fr_FR", "de_DE",
-                                                 "it_IT", "es_ES", "zn_CN", "ko_KR",
+                                                 "it_IT", "es_ES", "zh_CN", "ko_KR",
                                                  "nl_NL", "pt_PT", "ru_RU", "zh_TW" };
     u8 current_locale = GetLocaleIndex();
     if (current_locale != BAD_LOCALE) {
@@ -45,14 +45,13 @@ SDL_FORCE_INLINE u8
 GetLocaleIndex(void)
 {
     u8 current_locale;
+    Result result;
     if (R_FAILED(cfguInit())) {
         return BAD_LOCALE;
     }
-    if (R_FAILED(CFGU_GetSystemLanguage(&current_locale))) {
-        return BAD_LOCALE;
-    }
+    result = CFGU_GetSystemLanguage(&current_locale);
     cfguExit();
-    return current_locale;
+    return R_SUCCEEDED(result) ? current_locale : BAD_LOCALE;
 }
 
 /* vi: set sts=4 ts=4 sw=4 expandtab: */