Exemplo n.º 1
0
        protected void AddSupportedLanguage(string language, string ocrLanguageName)
        {
            CultureInfo culture;

            if (LocaleHelper.TryParseCulture(language, out culture))
            {
                SupportedLanguages[culture.Name] = ocrLanguageName;
                //SupportedLanguages[language] = ocrLanguageName;
            }
        }
Exemplo n.º 2
0
        protected bool AddSupportedLanguage(string language, string ocrLanguageName)
        {
            CultureInfo culture;

            if (LocaleHelper.TryParseCulture(language, out culture))
            {
                SupportedLanguages[culture.Name] = ocrLanguageName;
                //SupportedLanguages[language] = ocrLanguageName;
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        public static string GetLanguageKey(Dictionary <string, string> languages, string language)
        {
            CultureInfo cultureInfo;

            if (!LocaleHelper.TryParseCulture(language, out cultureInfo))
            {
                return(null);
            }

            List <string> systemLanguages = languages.Keys.ToList();

            string name = systemLanguages.FirstOrDefault(x => x.Equals(cultureInfo.Name, StringComparison.OrdinalIgnoreCase));

            if (name != null)
            {
                return(name);
            }

            string threeLetterISO = systemLanguages.FirstOrDefault(x => x.Equals(cultureInfo.ThreeLetterISOLanguageName, StringComparison.OrdinalIgnoreCase));

            if (threeLetterISO != null)
            {
                return(threeLetterISO);
            }

            string twoLetterISO = systemLanguages.FirstOrDefault(x => x.Equals(cultureInfo.TwoLetterISOLanguageName, StringComparison.OrdinalIgnoreCase));

            if (twoLetterISO != null)
            {
                return(twoLetterISO);
            }

            string displayName = systemLanguages.FirstOrDefault(x => x.Equals(cultureInfo.DisplayName, StringComparison.OrdinalIgnoreCase));

            if (displayName != null)
            {
                return(displayName);
            }

            return(null);
        }
Exemplo n.º 4
0
        private bool GetInfo(string capability, out LanguagePackType type, out string language, out string name)
        {
            type     = LanguagePackType.Unknown;
            language = null;
            name     = "Language." + capability;

            string[] splitted = capability.Split(new char[] { '.', '~' }, StringSplitOptions.RemoveEmptyEntries);

            string packageTypeStr = splitted[0].ToLower();

            switch (packageTypeStr)
            {
            case "basic": type = LanguagePackType.Basic; break;

            case "fonts": return(false);   //type = LanguagePackType.Font; break;

            case "ocr": type = LanguagePackType.OCR; break;

            case "handwriting": type = LanguagePackType.Handwriting; break;

            case "texttospeech": type = LanguagePackType.TextToSpeech; break;

            case "speech": type = LanguagePackType.Speech; break;

            default: Log("[WARNING] Unknown package type " + packageTypeStr); return(false);
            }

            try
            {
                language = LocaleHelper.GetCultureCode(splitted[1]);
            }
            catch (Exception e)
            {
                Log("Invalid language " + language + Environment.NewLine + "Exception: " + e);
            }

            return(true);
        }
Exemplo n.º 5
0
 private string GetLanguageKey(string language)
 {
     return(LocaleHelper.GetLanguageKey(SupportedLanguages, language));
 }
Exemplo n.º 6
0
 // Returns the API specific language name
 protected string GetSupportedLanguageName(string language)
 {
     return(LocaleHelper.GetSupportedLanguageName(SupportedLanguages, language));
 }
Exemplo n.º 7
0
 // Returns the culture for the language if supported by the current engine API
 protected CultureInfo GetSupportedLanguageCulture(string language)
 {
     return(LocaleHelper.GetSupportedLanguageCulture(SupportedLanguages, language));
 }