/// <summary>
 /// Initializes a new instance of the SettingsViewModel class.
 /// </summary>
 public SettingsViewModel()
 {
     AvailableLanguages = Configurator.returnAllLanguages();
     selectedLanguage   = AvailableLanguages.SingleOrDefault(l => l.FileName ==
                                                             Configurator.getLanguage());
     FindCommand = new RelayCommand(SelectGameFolder);
     if (!Configurator.getFirstStart())
     {
         Message = LocalizationHelper.getValueForKey("First_Start");
     }
     else
     {
         Message = "";
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Every item should start with Rarity in the first line.
        /// This will force the TradeClient to refetch the Public API's data if needed.
        /// </summary>
        public async Task FindAndSetLanguage(string itemDescription)
        {
            if (string.IsNullOrEmpty(itemDescription))
            {
                return;
            }

            var language = AvailableLanguages.Find(x => itemDescription.StartsWith(x.DescriptionRarity));

            if (language != null && SetLanguage(language.Name))
            {
                await cacheService.Clear();

                await initializeService.Initialize();
            }
        }
        private async void LoadLocales()
        {
            JsonObject json_res = await AvailableLanguages.getLocales("invoicing", CloureManager.lang);

            txtAdvice.Text                = json_res.GetNamedString("press_f2_to_finish");
            tbDatePrompt.Text             = json_res.GetNamedString("date");
            tbCompanyBranchPrompt.Text    = json_res.GetNamedString("branch");
            tbReceiptType.Text            = json_res.GetNamedString("receipt_type");
            tbCustomerPrompt.Text         = json_res.GetNamedString("customer");
            tbCustomerNamePrompt.Text     = json_res.GetNamedString("customer_name");
            tbSaldoPrompt.Text            = json_res.GetNamedString("balance");
            tbProductsServicesPrompt.Text = json_res.GetNamedString("products_services");
            tbQuantityPrompt.Text         = json_res.GetNamedString("quantity");
            tbProductPrompt.Text          = json_res.GetNamedString("product_service");
            tbObservationsPrompt.Text     = json_res.GetNamedString("observations");
        }
Ejemplo n.º 4
0
        public override void Initialize()
        {
            Files.Clear();
            foreach (var assembly in Assemblies.Keys)
            {
                var prefix  = Assemblies[assembly];
                var compare = !string.IsNullOrEmpty(prefix) ? f => f.StartsWith(prefix) && f.EndsWith(FileExtension)
                                : (Func <string, bool>)(f => f.EndsWith(FileExtension));
                var files = assembly.GetManifestResourceNames().Where(compare).ToList();

                var available = files.Select(s => s.Replace(FileExtension, string.Empty).Split('.').Where(st => st.Length == 2).LastOrDefault()).Distinct();
                var list      = AvailableLanguages.Union(available);
                _languages = list.ToList();
                Files.Add(assembly, files);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Initializes a new instance of the TranslateXML class.
        /// </summary>
        /// <param name="Logger">
        ///     The logger.
        /// </param>
        public TranslateXML(ConsoleLogger Logger)
            : base(Logger)
        {
            TranslationServiceFacade.Initialize();
            if (!TranslationServiceFacade.IsTranslationServiceReady())
            {
                this.Logger.WriteLine(LogLevel.Error, "Invalid translation service credentials. Use \"DocumentTranslatorCmd setcredentials\", or use the Document Translator Settings option.");
                return;
            }

            this.xmltotranslate = new Argument(
                "XML",
                true,
                "The XML file in need of translation");

            this.elementsdispositioncsv = new Argument(
                "Elements",
                true,
                "CSV file listing the elements to translate");

            this.fromlanguage = new Argument(
                "from",
                false,
                new[] { "Auto-Detect" },
                AvailableLanguages.GetLanguages().Result.Keys.ToArray(),
                true,
                "The source language. Auto-detect if no language specified.");

            this.tolanguage = new SimpleStringArgument(
                "to",
                true,
                new string[] { },
                AvailableLanguages.GetLanguages().Result.Keys.ToArray(),
                new[] { ',' },
                "The target language code, or comma-separated list of language codes.");

            this.generatecsv = new BooleanArgument(
                "generate",
                false,
                false,
                "Set to true if you want to generate a list of elements.");

            this.Arguments = new ArgumentList(
                new[] { this.xmltotranslate, this.elementsdispositioncsv, this.fromlanguage, this.tolanguage, this.generatecsv },
                Logger);
        }
Ejemplo n.º 6
0
 public override void LoadLanguage(string language = null)
 {
     if (language == null)
     {
         language = TranslationLoader.CurrentLanguage;
     }
     if (AvailableLanguages.Contains(language) && !LoadedLanguages.Contains(language))
     {
         foreach (var assembly in Files.Keys)
         {
             var files = Files[assembly].Where(f => f.Contains($".{language}.")).ToList();
             files.ForEach(f => LoadFile(f, assembly, language));
         }
     }
     _loaded.Add(language);
     Translate.AddLoaded(language);
 }
Ejemplo n.º 7
0
        public UILanguageProvider(SidekickSettings settings)
        {
            AvailableLanguages = SupportedLanguages
                                 .Select(x => new CultureInfo(x))
                                 .ToList();

            var current = AvailableLanguages.FirstOrDefault(x => x.Name == settings.Language_UI);

            if (current != null)
            {
                SetLanguage(settings.Language_UI);
            }
            else
            {
                SetLanguage(SupportedLanguages.FirstOrDefault());
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 ///     Change the language, this will only do something if the language actually changed.
 ///     All files are reloaded.
 /// </summary>
 /// <param name="ietf">The iso code for the language to use</param>
 /// <param name="cancellationToken">CancellationToken for the loading</param>
 /// <returns>Task</returns>
 public async Task ChangeLanguageAsync(string ietf, CancellationToken cancellationToken = default)
 {
     if (ietf == CurrentLanguage)
     {
         return;
     }
     Log.Verbose().WriteLine("Changing language to {0}", ietf);
     if (AvailableLanguages.ContainsKey(ietf))
     {
         CurrentLanguage = ietf;
         await ReloadAsync(cancellationToken).ConfigureAwait(false);
     }
     else
     {
         Log.Warn().WriteLine("Language {0} was not available.", ietf);
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="TranslateDocuments" /> class.
        /// </summary>
        /// <param name="Logger">
        ///     The logger.
        /// </param>
        public TranslateDocuments(ConsoleLogger Logger)
            : base(Logger)
        {
            try
            {
                _ = TranslationServiceFacade.Initialize();
            }
            catch (CredentialsMissingException ex)
            {
                this.Logger.WriteLine(LogLevel.Error, ex.Message);
            }
            if (!TranslationServiceFacade.IsTranslationServiceReady())
            {
                this.Logger.WriteLine(LogLevel.Error, "Invalid translation service credentials. Use \"DocumentTranslatorCmd setcredentials\"");
                return;
            }

            this.sourceDocuments = new SimpleStringArgument(
                "Documents",
                true,
                new[] { ',' },
                "Document to translate, or list of documents separated by comma, or a wildcard. Wildcard recurses through subfolders.");

            this.sourceLanguage = new Argument(
                "from",
                false,
                new[] { "Auto-Detect" },
                AvailableLanguages.GetLanguages().Result.Keys.ToArray(),
                true,
                "The source language. Auto-detect if no language specified.");

            this.targetLanguages = new SimpleStringArgument(
                "to",
                true,
                new string[] { },
                AvailableLanguages.GetLanguages().Result.Keys.ToArray(),
                new[] { ',' },
                "The target language code, or comma-separated list of language codes.");

            this.Arguments = new ArgumentList(
                new[] { this.sourceDocuments, this.sourceLanguage, this.targetLanguages },
                Logger);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Loads all languages.
        /// </summary>
        /// <param name="logger">The <see cref="ILogger" /> instance used within the sided API.</param>
        /// <param name="assetManager">The <see cref="IAssetManager" /> instance used within the sided API.</param>
        /// <param name="defaultLanguage">The language code to set as the default/fallback language for the game.</param>
        public static void Load(ILogger logger, IAssetManager assetManager, string defaultLanguage = "en")
        {
            CurrentLocale = defaultLanguage;

            var languageFile = Path.Combine(GamePaths.AssetsPath, "game", "lang", "languages.json");
            var json         = JsonObject.FromJson(File.ReadAllText(languageFile)).AsArray();

            foreach (var jsonObject in json)
            {
                var languageCode = jsonObject["code"].AsString();
                LoadLanguage(logger, assetManager, languageCode, languageCode != defaultLanguage);
            }

            if (!AvailableLanguages.ContainsKey(defaultLanguage))
            {
                logger.Error("Language '{0}' not found. Will default to english.", defaultLanguage);
                CurrentLocale = "en";
            }
        }
Ejemplo n.º 11
0
        public void AddAvailableLanguage(string languageShortName)
        {
            if (AvailableLanguages.Count == 0)
            {
                AvailableLanguages.Add(languageShortName);
            }
            else
            {
                foreach (string language in AvailableLanguages)
                {
                    if (language == languageShortName)
                    {
                        return;
                    }
                }

                AvailableLanguages.Add(languageShortName);
                return;
            }
        }
Ejemplo n.º 12
0
        public static async Task <string> GetAllLanguages()
        {
            StringWriter writer = new StringWriter();
            Dictionary <string, string> languagelist = new Dictionary <string, string>();

            languagelist = await AvailableLanguages.GetLanguages();

            writer.WriteLine("{0}\t{1}\t{2}", "Language", "Language Code", "Display Name");
            writer.WriteLine("------------------------------------------------------");
            foreach (KeyValuePair <string, string> language in languagelist.ToList())
            {
                Dictionary <string, string> languagesinlanguage = await AvailableLanguages.GetLanguages(language.Key);

                foreach (KeyValuePair <string, string> lang in languagesinlanguage)
                {
                    writer.WriteLine("{0}\t{1}\t{2}", language.Key, lang.Key, lang.Value);
                }
                writer.WriteLine("\n\n");
            }

            return(writer.ToString());
        }
Ejemplo n.º 13
0
        private void LogMissingTranslation(string textId, string defaultText)
        {
            if (LogOutMissingTranslations)
            {
                AvailableLanguages.ToList().ForEach(delegate(string languageId)
                {
                    if (!TranslationsDictionary.ContainsKey(textId) ||
                        !TranslationsDictionary[textId].ContainsKey(languageId))
                    {
                        if (!MissingTranslations.ContainsKey(textId))
                        {
                            MissingTranslations.Add(textId, new SortedDictionary <string, string>());
                        }

                        MissingTranslations[textId][languageId] = $"default text : {defaultText}";
                    }
                });

                File.WriteAllText(missingTranslationsFileName,
                                  JsonConvert.SerializeObject(MissingTranslations, Formatting.Indented));
            }
        }
Ejemplo n.º 14
0
        internal void Load(string filePath)
        {
            var xmlDocument = new XmlDocument();

            xmlDocument.Load(filePath);

            var fileNamePart = filePath.Split('\\').Last().Split('.');
            var languageId   = fileNamePart.First().Split('_').Last().ToLowerInvariant();

            _currentFileNameNoExtension = fileNamePart.First().Split('_').First();
            if (!AvailableLanguages.Contains(languageId))
            {
                AvailableLanguages.Add(languageId);
            }

            var rootNode = xmlDocument.SelectSingleNode("Language");

            foreach (XmlNode childNode in rootNode.ChildNodes)
            {
                ReadXmlNode(childNode, languageId, "Language", LangStrings);
            }
        }
        private void ManipulateUX(AvailableLanguages Language, bool ShowProgressBar, bool ShowDownloadButton, bool ShowCancelButton, bool ShowRemoveButton)
        {
            if (ShowProgressBar)
            {
                ProgressBarList[(int)Language].Visibility = Visibility.Visible;
            }
            else
            {
                ProgressBarList[(int)Language].Visibility = Visibility.Collapsed;
            }

            if (ShowDownloadButton)
            {
                DownloadButtonList[(int)Language].Visibility = Visibility.Visible;
            }
            else
            {
                DownloadButtonList[(int)Language].Visibility = Visibility.Collapsed;
            }

            if (ShowCancelButton)
            {
                CancelButtonList[(int)Language].Visibility = Visibility.Visible;
            }
            else
            {
                CancelButtonList[(int)Language].Visibility = Visibility.Collapsed;
            }

            if (ShowRemoveButton)
            {
                RemoveButtonList[(int)Language].Visibility = Visibility.Visible;
            }
            else
            {
                RemoveButtonList[(int)Language].Visibility = Visibility.Collapsed;
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 ///     Populate available source and target languages.
 /// </summary>
 public void PopulateAvailableLanguages()
 {
     this.sourceLanguageList.Clear();
     this.targetLanguageList.Clear();
     if (!TranslationServiceFacade.UseCustomEndpoint)
     {
         this.sourceLanguageList.Add(Properties.Resources.Common_AutoDetect);
     }
     try
     {
         targetLanguageList.AddRange(AvailableLanguages.GetLanguages().Result.Values);
     }
     catch (Exception ex) {
         this.StatusText = String.Format("{0}\n{1}", Properties.Resources.Error_LanguageList, ex.Message);
         this.NotifyPropertyChanged("StatusText");
         return;
     };
     this.targetLanguageList.Sort();
     this.sourceLanguageList.AddRange(this.targetLanguageList);
     this.NotifyPropertyChanged("SourceLanguageList");
     this.NotifyPropertyChanged("TargetLanguageList");
     Debug.WriteLine("DocumentTranslation.cs: targetLanguageList.Count: {0}", targetLanguageList.Count);
 }
Ejemplo n.º 17
0
        private bool SetLanguage(string name)
        {
            var language = AvailableLanguages.Find(x => x.Name == name);

            if (language == null)
            {
                logger.Information("Couldn't find language matching {language}.", name);
                return(false);
            }

            if (Language == null || Language.DescriptionRarity != language.DescriptionRarity)
            {
                logger.Information("Changed active language support to {language}.", language.Name);
                Language = (ILanguage)Activator.CreateInstance(language.ImplementationType);

                settings.Language_Parser = name;
                settings.Save();

                return(true);
            }

            return(false);
        }
Ejemplo n.º 18
0
        public RootViewModel(
            IServerResponseService serverResponseService,
            IFileProcessService fileProcessService,
            IConfigurationService _configurationService,
            IRecordService recordService)
        {
            _recordService = recordService;
            _recordService.RecordStopped += delegate { IsTranscribingInProgress = false; };
            _recordService.InfoMessage   += delegate(object _sender, string message) { InfoMessage = message; };
            _recordService.RecordLevel   += delegate(object _sender, float level) { RecordLevel = level; };

            _fontSizes        = new int[] { 8, 12, 14, 16, 18, 20, 22, 24, 26 };
            _selectedFontSize = _fontSizes[3];

            _transportService              = Mvx.IoCProvider.Resolve <ITransportService>();
            _transportService.InfoMessage += delegate(object _sender, string message) { InfoMessage = message; };

            _configurationService = new ConfigurationService();

            _fileProcessService = fileProcessService;
            _fileProcessService.PercentageTranscribed += UpdatePercentageTranscribed;
            _fileProcessService.InfoMessage           += delegate(object _sender, string message) { InfoMessage = message; };

            _serverResponseService = serverResponseService;
            _serverResponseService.HandledServerResponse += delegate(object _sender, string resp) { Transcription = resp; };
            _serverResponseService.InfoMessage           += delegate(object _sender, string message) { InfoMessage = message; };

            ToggleTranscriptionCommand = new MvxCommand(StartTranscribing);
            ClearTextCommand           = new MvxCommand(_serverResponseService.Clear);
            TranscribeFileCommand      = new MvxAsyncCommand(TranscribeFile);

            AvailableLanguages = _configurationService.GetLanguages().ToArray();
            if (AvailableLanguages.Count() != 0)
            {
                SelectedLanguage = AvailableLanguages.Where(x => x.Key.ToLower() == "russian").FirstOrDefault();
            }
        }
Ejemplo n.º 19
0
 /// <summary>Loads all available language files from the specificed folder</summary>
 public static void LoadLanguageFiles(string LanguageFolder)
 {
     if (!Directory.Exists(LanguageFolder))
     {
         MessageBox.Show(@"The default language files have been moved or deleted.");
         LoadEmbeddedLanguage();
         return;
     }
     try {
         string[] LanguageFiles = Directory.GetFiles(LanguageFolder, "*.xlf");
         if (LanguageFiles.Length == 0)
         {
             MessageBox.Show(@"No valid language files were found.");
             LoadEmbeddedLanguage();
             return;
         }
         foreach (var File in LanguageFiles)
         {
             try
             {
                 using (FileStream stream = new FileStream(File, FileMode.Open, FileAccess.Read))
                     using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
                     {
                         Language l = new Language(reader, System.IO.Path.GetFileNameWithoutExtension(File));
                         AvailableLanguages.Add(l);
                     }
             }
             catch
             {
                 //Corrupt language file? Just ignore
             }
         }
     } catch {
         MessageBox.Show(@"An error occured whilst attempting to load the default language files.");
         LoadEmbeddedLanguage();
     }
 }
Ejemplo n.º 20
0
        /* Load localization for chosen language
         */
        public static void LoadLocalization(AvailableLanguages language)
        {
            string file;

            switch (language)
            {
            case AvailableLanguages.English:
                file = Properties.Resources.English;
                break;

            case AvailableLanguages.Russian:
                file = Properties.Resources.Russian;
                break;

            default:
                file = Properties.Resources.English;
                break;
            }

            XmlSerializer serializer   = new XmlSerializer(typeof(LocalizedStrings));
            MemoryStream  memoryStream = new MemoryStream(Encoding.Unicode.GetBytes(file));

            localized = (LocalizedStrings)serializer.Deserialize(memoryStream);
            memoryStream.Close();

            userLogKeywords = new Dictionary <string, Color>()
            {
                { localized.regExWhite, Color.White },
                { localized.regExBlack, Color.Black },
                { localized.regExLoaded, Color.Lime },
                { localized.regExSaved, Color.Red },
                { localized.regExWon, Color.Coral }
            };

            currentLanguage = language;
        }
        private void LoadPage()
        {
            #region GetAvailableLanguages
            string saveDir     = Directory.GetCurrentDirectory();
            bool   ErrorsFound = false;

            if (Directory.GetFiles(saveDir + "/Languages").Length > 1)
            {
                foreach (var file in Directory.GetFiles(saveDir + "/Languages", "*.lang"))
                {
                    StreamReader langReader = new StreamReader(file);
                    string       rawObj     = langReader.ReadToEnd();
                    try
                    {
                        LanguageDataModel tempObj = JsonConvert.DeserializeObject <LanguageDataModel>(rawObj);

                        if (tempObj != null)
                        {
                            AvailableLanguages.Add(tempObj);
                        }
                        // MessageBox.Show(file);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        ErrorsFound = true;
                    }
                }
                if (ErrorsFound)
                {
                    MessageBox.Show("Errors Found");
                }
            }
            else
            {
                SelectedLanguage = new LanguageDataModel();
            }
            #endregion

            #region LoadSavedSettings
            if (File.Exists("Settings/settings.json"))
            {
                StreamReader settingsReader = new StreamReader("Settings/settings.json");
                try
                {
                    SettingsDataModel serializedData = JsonConvert.DeserializeObject <SettingsDataModel>(settingsReader.ReadToEnd());
                    // MessageBox.Show("loaded");
                    SelectedLanguage = AvailableLanguages.Single(lang => lang.LanguageName == serializedData.SelectedLanguage.LanguageName);
                    if (SelectedLanguage == null)
                    {
                        SelectedLanguage = new LanguageDataModel();
                    }


                    SelectedLanguageIndex = AvailableLanguages.IndexOf(SelectedLanguage);
                    HomeLocation          = serializedData.HomeLocation;
                    SelectedUnitIndex     = Units.IndexOf(serializedData.Unit);
                }catch (Exception)
                {
                    SelectedLanguage = new LanguageDataModel();
                }

                settingsReader.Dispose();
            }


            #endregion
        }
Ejemplo n.º 22
0
        public TemplateDocumentationPage(string templateFile, string relativeTemplateDirectory, TemplateDirectory templateDir)
        {
            _relativeTemplateDirectory = relativeTemplateDirectory;
            TemplateFile = templateFile;
            TemplateDir  = templateDir;

            string templateXMLFile = Path.Combine(Path.GetDirectoryName(templateFile), Path.GetFileNameWithoutExtension(templateFile) + ".xml");

            if (!File.Exists(templateXMLFile))
            {
                throw new Exception(string.Format("Missing meta infos for template {0}!", templateFile));
            }

            TemplateXML = XElement.Load(templateXMLFile);

            BitmapFrame icon = null;

            if (TemplateXML.Element("icon") != null && TemplateXML.Element("icon").Attribute("file") != null)
            {
                var iconFile = Path.Combine(Path.GetDirectoryName(templateFile), TemplateXML.Element("icon").Attribute("file").Value);
                if (iconFile == null || !File.Exists(iconFile))
                {
                    iconFile = Path.Combine(Path.GetDirectoryName(templateFile), Path.GetFileNameWithoutExtension(templateFile) + ".png");
                }
                if (File.Exists(iconFile))
                {
                    try
                    {
                        icon = BitmapFrame.Create(new BitmapImage(new Uri(iconFile)));
                        Icon = iconFile;
                    }
                    catch (Exception)
                    {
                        icon = null;
                        Icon = "";
                    }
                }
            }

            var authorElement = XMLHelper.FindLocalizedChildElement(TemplateXML, "author");

            if (authorElement != null)
            {
                AuthorName = authorElement.Value;
            }

            var relevantPlugins = TemplateXML.Element("relevantPlugins");

            if (relevantPlugins != null)
            {
                RelevantPlugins = new List <string>();
                foreach (var plugin in relevantPlugins.Elements("plugin"))
                {
                    var name = plugin.Attribute("name");
                    if (name != null)
                    {
                        RelevantPlugins.Add(name.Value);
                    }
                }
            }

            foreach (var title in TemplateXML.Elements("title"))
            {
                var langAtt = title.Attribute("lang");
                if (langAtt != null && !AvailableLanguages.Contains(langAtt.Value))
                {
                    Localizations.Add(langAtt.Value, new LocalizedTemplateDocumentationPage(this, langAtt.Value, icon));
                }
            }
            if (!Localizations.ContainsKey("en"))
            {
                throw new Exception("Documentation should at least support english language!");
            }
        }
Ejemplo n.º 23
0
 public void RemoveAvailableLanguage(string languageShortName)
 {
     AvailableLanguages.Remove(languageShortName);
 }
Ejemplo n.º 24
0
        /// <summary>
        ///     The execute.
        /// </summary>
        /// <returns>
        ///     The <see cref="bool" />.
        /// </returns>
        public override bool Execute()
        {
            int           documentcount = 0;
            List <String> listoffiles   = new List <string>();

            //Expand wildcard, if name specification contains *
            if (this.sourceDocuments.Values.ToArray().Any(file => file.ToString().Contains("*")))
            {
                foreach (string filename in this.sourceDocuments.Values.ToArray())
                {
                    int      lastBackslashPosition = filename.LastIndexOf('\\') + 1;
                    string   path         = filename.Substring(0, lastBackslashPosition);
                    string   filenameOnly = filename.Substring(lastBackslashPosition);
                    String[] filelist     = Directory.GetFiles(path, filenameOnly, SearchOption.AllDirectories);
                    listoffiles.AddRange(filelist);
                }
            }
            else  //no * in the file name
            {
                foreach (var file in this.sourceDocuments.ValueString.Split(','))
                {
                    listoffiles.Add(file);
                }
            }

            try
            {
                var model = new CommentTranslationModel
                {
                    SourceLanguage =
                        this.sourceLanguage.ValueString ?? "Auto-Detect",
                    TargetLanguage = this.targetLanguages.ValueString
                };

                foreach (var file in listoffiles)
                {
                    if (!File.Exists(file))
                    {
                        Logger.WriteLine(LogLevel.Error, String.Format("Specified document {0} does not exist. ", file));
                    }
                    foreach (var language in this.targetLanguages.Values)
                    {
                        try
                        {
                            this.Logger.WriteLine(
                                LogLevel.Msg,
                                string.Format(
                                    "Translating document {0} to language {1}.",
                                    file,
                                    language));
                            model.TargetPath = file;
                            var sourceLanguageExpanded = String.IsNullOrEmpty(this.sourceLanguage.ValueString) ||
                                                         this.sourceLanguage.ValueString.Equals("Auto-Detect")
                                                             ? "Auto-Detect"
                                                             : AvailableLanguages.GetLanguages().Result[this.sourceLanguage.ValueString];
                            string languagename = TranslationServiceFacade.LanguageCodeToLanguageName(language.ToString());

                            DocumentTranslationManager.DoTranslation(
                                file,
                                false,
                                sourceLanguageExpanded,
                                languagename);
                            this.Logger.WriteLine(
                                LogLevel.Msg,
                                string.Format(
                                    "-- Translated document name {0} to language {1}.",
                                    file,
                                    language));
                            documentcount++;
                        }
                        catch (Exception ex)
                        {
                            this.Logger.WriteLine(
                                LogLevel.Error,
                                string.Format(
                                    "Error while processing file: {0} to language {1} with error: {2}",
                                    model.TargetPath,
                                    language,
                                    ex.Message));
                            throw;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.Logger.WriteException(ex);
                Console.ReadLine();
                return(false);
            }

            this.Logger.WriteLine(LogLevel.Msg, string.Format("Documents translated successfully: {0}.", documentcount));
            return(true);
        }
        private CommonLanguageContextProvider SetDefaultLanguage(string value)
        {
            DefaultLanguage = AvailableLanguages.Contains(value) ? value : null;

            return(this);
        }
        private string LookForHttpSessionContext()
        {
            var sessionLanguageContext = HttpContext.Current.Session[SessionContextKey] as string;

            return(AvailableLanguages.Contains(sessionLanguageContext) ? sessionLanguageContext : null);
        }
Ejemplo n.º 27
0
        private void SetupMenu()
        {
            var languages = GetAvailableLanguages();

            AvailableLanguages.AddRange(languages);
        }
Ejemplo n.º 28
0
 public List <string> GetLanguages()
 {
     return(AvailableLanguages.Select(l => l.Name).ToList());
 }