Beispiel #1
0
        void LoadLanguagePacks()
        {
            var fileEntries = Directory.GetFiles("vocabulary");

            foreach (var fileName in fileEntries)
            {
                // do something with fileName
                var info      = new FileInfo(fileName);
                var _fileName = fileName;
                var name      = info.Name;
                if (name.Contains(".xml"))
                {
                    name = name.Replace(".xml", "");

                    var languagePack = new Models.LanguagePack();
                    languagePack.Name = name;
                    languagePack.Info = info;

                    //Get words
                    var sr           = new  StreamReader(_fileName);
                    var deserializer = new XmlSerializer(typeof(List <Word>));
                    languagePack.Words = (List <Word>)deserializer.Deserialize(sr);

                    languagePack.NativeLanguage = Client.NativeLanguage;
                    languagePack.TargetLanguage = Client.TargetLanguage;

                    if (LanguagePacks == null)
                    {
                        LanguagePacks = new ObservableCollection <LanguagePack>();
                    }
                    LanguagePacks.Add(languagePack);
                }
            }
        }
Beispiel #2
0
        private async Task <string> GetLanguagePackName()
        {
            foreach (var languageResolver in _languageResolvers)
            {
                var code = await languageResolver.GetLanguageCode();

                if (string.IsNullOrWhiteSpace(code))
                {
                    continue;
                }

                var pack = LanguagePacks.FirstOrDefault(x => code.Contains(x));

                if (!string.IsNullOrEmpty(pack))
                {
                    return(pack);
                }
            }

            if (string.IsNullOrEmpty(_transmogrifyConfig.DefaultLanguage))
            {
                throw new
                      TransmogrifyFailedToResolveLanguageCode("Couldn't resolve a language code and no default language was set.");
            }

            return(_transmogrifyConfig.DefaultLanguage);
        }
Beispiel #3
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            LoadLanguagePacks();

            var packTitles = LanguagePacks.Select(x => x.Name).Distinct().ToList();

            TableView.DataSource = new SkillsTableDataSource(packTitles);
        }
Beispiel #4
0
 public static void SetLanguagePack(LanguagePacks langPackId)
 {
     switch (langPackId) {
         case LanguagePacks.En_US:
             //Activator.CreateInstance(new System.typ
             //LanguagePack = (LanguagePack)(new LanguagePack_En_US());
             break;
         case LanguagePacks.Ru_ru:
             //LanguagePack.LanguagePack = (LanguagePack)(new LanguagePack_Ru_ru());
             break;
         default:
             throw new Exception("Invalid value for LanguagePacks");
     }
 }
Beispiel #5
0
        public static void SetLanguagePack(LanguagePacks langPackId)
        {
            switch (langPackId)
            {
            case LanguagePacks.En_US:
                //Activator.CreateInstance(new System.typ
                //LanguagePack = (LanguagePack)(new LanguagePack_En_US());
                break;

            case LanguagePacks.Ru_ru:
                //LanguagePack.LanguagePack = (LanguagePack)(new LanguagePack_Ru_ru());
                break;

            default:
                throw new Exception("Invalid value for LanguagePacks");
            }
        }