public async Task <IHttpActionResult> GetAvailableLanguages()
        {
            var model = await _translationProvider.GetAvailableLanguagesAsync();

            if (model == null)
            {
                return(NotFound());
            }

            //model = model.Where(rec => rec.Code == "en" || rec.Code == "es").ToList();

            return(Ok(model));
        }
Example #2
0
        public async Task <TranslatedPackagesModel> CreatePackagesLanguages(TranslatePackageModelRequest model, string baseLangPath, string folderFile)
        {
            var languageAvailable = await _translationProvider.GetAvailableLanguagesAsync();

            TranslatedPackagesModel tranlatedPackages = new TranslatedPackagesModel();

            if (model.AllLanguages)
            {
                foreach (var language in languageAvailable.Where(x => x.Code != "en" && x.Code != "es"))
                {
                    model.Code = language.Code;
                    tranlatedPackages.translatedPackages.Add(await GenerateFile(model, baseLangPath, folderFile, language.Name));
                }
            }
            else
            {
                var languageName = languageAvailable.FirstOrDefault(x => x.Code == model.Code).Name;
                tranlatedPackages.translatedPackages.Add(await GenerateFile(model, baseLangPath, folderFile, languageName));
            }
            return(tranlatedPackages);
        }