From 954aa1112a9f28127fa20cbc2349f4eed99fb1cf Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 6 Sep 2019 09:44:02 -0400 Subject: [PATCH] added locale names dictionary --- src/App/Services/MobileI18nService.cs | 53 +++++++++++++++++++++++++++ src/Core/Abstractions/II18nService.cs | 4 +- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/App/Services/MobileI18nService.cs b/src/App/Services/MobileI18nService.cs index ba2c3ed95..cf3e8fc1b 100644 --- a/src/App/Services/MobileI18nService.cs +++ b/src/App/Services/MobileI18nService.cs @@ -1,6 +1,7 @@ using Bit.App.Resources; using Bit.Core.Abstractions; using System; +using System.Collections.Generic; using System.Globalization; using System.Reflection; using System.Resources; @@ -18,6 +19,7 @@ namespace Bit.App.Services private readonly CultureInfo _defaultCulture = new CultureInfo("en-US"); private bool _inited; private StringComparer _stringComparer; + private Dictionary _localeNames; public MobileI18nService(CultureInfo systemCulture) { @@ -36,6 +38,57 @@ namespace Bit.App.Services return _stringComparer; } } + public Dictionary LocaleNames + { + get + { + if(_localeNames == null) + { + _localeNames = new Dictionary + { + ["af"] = "Afrikaans", + ["bg"] = "български", + ["ca"] = "català", + ["cs"] = "čeština", + ["da"] = "dansk", + ["de"] = "Deutsch", + ["el"] = "Ελληνικά", + ["en"] = "English", + ["en-GB"] = "English (British)", + ["eo"] = "Esperanto", + ["es"] = "español", + ["et"] = "eesti", + ["fa"] = "فارسی", + ["fi"] = "suomi", + ["fr"] = "français", + ["he"] = "עברית", + ["hi"] = "हिन्दी", + ["hr"] = "hrvatski", + ["hu"] = "magyar", + ["id"] = "Bahasa Indonesia", + ["it"] = "italiano", + ["ja"] = "日本語", + ["ko"] = "한국어", + ["nb"] = "norsk (bokmål)", + ["nl"] = "Nederlands", + ["pl"] = "polski", + ["pt-BR"] = "português do Brasil", + ["pt-PT"] = "português", + ["ro"] = "română", + ["ru"] = "русский", + ["sk"] = "slovenčina", + ["sv"] = "svenska", + ["th"] = "ไทย", + ["tr"] = "Türkçe", + ["uk"] = "українська", + ["vi"] = "Tiếng Việt", + ["zh-CN"] = "中文(中国大陆)", + ["zh-TW"] = "中文(台灣)" + }; + } + return _localeNames; + } + } public void Init(CultureInfo culture = null) { diff --git a/src/Core/Abstractions/II18nService.cs b/src/Core/Abstractions/II18nService.cs index 69e1b8fe2..f8652a89b 100644 --- a/src/Core/Abstractions/II18nService.cs +++ b/src/Core/Abstractions/II18nService.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Globalization; namespace Bit.Core.Abstractions @@ -7,7 +8,8 @@ namespace Bit.Core.Abstractions { CultureInfo Culture { get; set; } StringComparer StringComparer { get; } + Dictionary LocaleNames { get; } string T(string id, string p1 = null, string p2 = null, string p3 = null); string Translate(string id, string p1 = null, string p2 = null, string p3 = null); } -} \ No newline at end of file +}