From a760eb0d6a27e2c240e64a15276eaf7ba616a4ab Mon Sep 17 00:00:00 2001 From: hjhun <36876573+hjhun@users.noreply.github.com> Date: Fri, 1 Oct 2021 20:35:24 +0900 Subject: [PATCH 1/1] Fix getting fallback cultureinfo (#3635) Signed-off-by: Hwankyu Jhun --- .../Tizen.Applications/CoreApplication.cs | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs b/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs index f82edd1..dd23082 100644 --- a/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs @@ -319,37 +319,43 @@ namespace Tizen.Applications private CultureInfo GetFallbackCultureInfo(ULocale uLocale) { - string locale = uLocale.Locale.Replace("_", "-"); - CultureInfo fallbackCultureInfo = GetCultureInfo(locale); + CultureInfo fallbackCultureInfo = null; + string locale = string.Empty; - if (fallbackCultureInfo == null && uLocale.Script != null && uLocale.Country != null) + if (uLocale.Locale != null) + { + locale = uLocale.Locale.Replace("_", "-"); + fallbackCultureInfo = GetCultureInfo(locale); + } + + if (fallbackCultureInfo == null && uLocale.Language != null && uLocale.Script != null && uLocale.Country != null) { locale = uLocale.Language + "-" + uLocale.Script + "-" + uLocale.Country; fallbackCultureInfo = GetCultureInfo(locale); } - if (fallbackCultureInfo == null && uLocale.Script != null) + if (fallbackCultureInfo == null && uLocale.Language != null && uLocale.Script != null) { locale = uLocale.Language + "-" + uLocale.Script; fallbackCultureInfo = GetCultureInfo(locale); } - if (fallbackCultureInfo == null && uLocale.Country != null) + if (fallbackCultureInfo == null && uLocale.Language != null && uLocale.Country != null) { locale = uLocale.Language + "-" + uLocale.Country; fallbackCultureInfo = GetCultureInfo(locale); } + if (fallbackCultureInfo == null && uLocale.Language != null) + { + locale = uLocale.Language; + fallbackCultureInfo = GetCultureInfo(locale); + } + if (fallbackCultureInfo == null) { - try - { - fallbackCultureInfo = new CultureInfo(uLocale.Language); - } - catch (CultureNotFoundException) - { - fallbackCultureInfo = new CultureInfo("en"); - } + locale = "en"; + fallbackCultureInfo = GetCultureInfo(locale); } return fallbackCultureInfo; -- 2.7.4