GetLanguage2Name() public method

public GetLanguage2Name ( string inLanguage ) : string
inLanguage string
return string
        public static void AddUIDictionaryToDom(HtmlDom pageDom, CollectionSettings collectionSettings)
        {
            XmlElement dictionaryScriptElement = pageDom.RawDom.SelectSingleNode("//script[@id='ui-dictionary']") as XmlElement;
            if (dictionaryScriptElement != null)
                dictionaryScriptElement.ParentNode.RemoveChild(dictionaryScriptElement);

            dictionaryScriptElement = pageDom.RawDom.CreateElement("script");
            dictionaryScriptElement.SetAttribute("type", "text/javascript");
            dictionaryScriptElement.SetAttribute("id", "ui-dictionary");
            var d = new Dictionary<string, string>();

            d.Add(collectionSettings.Language1Iso639Code, collectionSettings.Language1Name);
            if (!String.IsNullOrEmpty(collectionSettings.Language2Iso639Code) && !d.ContainsKey(collectionSettings.Language2Iso639Code))
                d.Add(collectionSettings.Language2Iso639Code, collectionSettings.GetLanguage2Name(collectionSettings.Language2Iso639Code));
            if (!String.IsNullOrEmpty(collectionSettings.Language3Iso639Code) && !d.ContainsKey(collectionSettings.Language3Iso639Code))
                d.Add(collectionSettings.Language3Iso639Code, collectionSettings.GetLanguage3Name(collectionSettings.Language3Iso639Code));

            d.Add("vernacularLang", collectionSettings.Language1Iso639Code);//use for making the vernacular the first tab
            d.Add("{V}", collectionSettings.Language1Name);
            d.Add("{N1}", collectionSettings.GetLanguage2Name(collectionSettings.Language2Iso639Code));
            d.Add("{N2}", collectionSettings.GetLanguage3Name(collectionSettings.Language3Iso639Code));

            AddLocalizedHintContentsToDictionary(pageDom, d, collectionSettings);

            dictionaryScriptElement.InnerText = String.Format("function GetDictionary() {{ return {0};}}", JsonConvert.SerializeObject(d));

            pageDom.Head.InsertAfter(dictionaryScriptElement, pageDom.Head.LastChild);
        }
        public static void AddUIDictionaryToDom(HtmlDom pageDom, CollectionSettings collectionSettings)
        {
            CheckDynamicStrings();

            // add dictionary script to the page
            XmlElement dictionaryScriptElement = pageDom.RawDom.SelectSingleNode("//script[@id='ui-dictionary']") as XmlElement;
            if (dictionaryScriptElement != null)
                dictionaryScriptElement.ParentNode.RemoveChild(dictionaryScriptElement);

            dictionaryScriptElement = pageDom.RawDom.CreateElement("script");
            dictionaryScriptElement.SetAttribute("type", "text/javascript");
            dictionaryScriptElement.SetAttribute("id", "ui-dictionary");
            var d = new Dictionary<string, string>();

            d.Add(collectionSettings.Language1Iso639Code, collectionSettings.Language1Name);
            if (!String.IsNullOrEmpty(collectionSettings.Language2Iso639Code))
                SafelyAddLanguage(d, collectionSettings.Language2Iso639Code,
                    collectionSettings.GetLanguage2Name(collectionSettings.Language2Iso639Code));
            if (!String.IsNullOrEmpty(collectionSettings.Language3Iso639Code))
                SafelyAddLanguage(d, collectionSettings.Language3Iso639Code,
                    collectionSettings.GetLanguage3Name(collectionSettings.Language3Iso639Code));

            SafelyAddLanguage(d, "vernacularLang", collectionSettings.Language1Iso639Code);//use for making the vernacular the first tab
            SafelyAddLanguage(d, "{V}", collectionSettings.Language1Name);
            SafelyAddLanguage(d, "{N1}", collectionSettings.GetLanguage2Name(collectionSettings.Language2Iso639Code));
            SafelyAddLanguage(d, "{N2}", collectionSettings.GetLanguage3Name(collectionSettings.Language3Iso639Code));

            // TODO: Eventually we need to look through all .bloom-translationGroup elements on the current page to determine
            // whether there is text in a language not yet added to the dictionary.
            // For now, we just add a few we know we need
            AddSomeCommonNationalLanguages(d);

            MakePageLabelLocalizable(pageDom, d);

            // Hard-coded localizations for 2.0
            AddHtmlUiStrings(d);

            // Do this last, on the off-chance that the page contains a localizable string that matches
            // a language code.
            AddLanguagesUsedInPage(pageDom.RawDom, d);

            dictionaryScriptElement.InnerText = String.Format("function GetInlineDictionary() {{ return {0};}}", JsonConvert.SerializeObject(d));

            // add i18n initialization script to the page
            //AddLocalizationTriggerToDom(pageDom);

            pageDom.Head.InsertAfter(dictionaryScriptElement, pageDom.Head.LastChild);

            _collectDynamicStrings = false;
        }
        private void UpdateDisplay()
        {
            _language1Name.Text = string.Format("{0} ({1})", _collectionSettings.GetLanguage1Name(LocalizationManager.UILanguageId), _collectionSettings.Language1Iso639Code);
            _language2Name.Text = string.Format("{0} ({1})", _collectionSettings.GetLanguage2Name(LocalizationManager.UILanguageId), _collectionSettings.Language2Iso639Code);

            if (string.IsNullOrEmpty(_collectionSettings.Language3Iso639Code))
            {
                _language3Name.Text          = "--";
                _removeLanguage3Link.Visible = false;
            }
            else
            {
                _language3Name.Text          = string.Format("{0} ({1})", _collectionSettings.GetLanguage3Name(LocalizationManager.UILanguageId), _collectionSettings.Language3Iso639Code);
                _removeLanguage3Link.Visible = true;
            }

            _restartReminder.Visible = _restartRequired;
            _okButton.Text           = _restartRequired ? LocalizationManager.GetString("CollectionSettingsDialog.Restart", "Restart", "If you make certain changes in the settings dialog, the OK button changes to this.") : LocalizationManager.GetString("Common.OKButton", "&OK");

            _xmatterPackCombo.Items.Clear();
            _xmatterPackCombo.Items.AddRange(_xmatterPackFinder.All.ToArray());
            _xmatterPackCombo.SelectedItem = _xmatterPackFinder.FindByKey(_collectionSettings.XMatterPackName);
            if (_xmatterPackCombo.SelectedItem == null)             //if something goes wrong
            {
                _xmatterPackCombo.SelectedItem = _xmatterPackFinder.FactoryDefault;
            }
        }
        private void UpdateDisplay()
        {
            string defaultFontText =
                LocalizationManager.GetString("CollectionSettingsDialog.BookMakingTab.DefaultFontFor", "Default Font for {0}", "{0} is a language name.");
            var lang1UiName = _collectionSettings.GetLanguage1Name(LocalizationManager.UILanguageId);
            var lang2UiName = _collectionSettings.GetLanguage2Name(LocalizationManager.UILanguageId);

            _language1Name.Text      = string.Format("{0} ({1})", lang1UiName, _collectionSettings.Language1Iso639Code);
            _language2Name.Text      = string.Format("{0} ({1})", lang2UiName, _collectionSettings.Language2Iso639Code);
            _language1FontLabel.Text = string.Format(defaultFontText, lang1UiName);
            _language2FontLabel.Text = string.Format(defaultFontText, lang2UiName);

            var lang3UiName = string.Empty;

            if (string.IsNullOrEmpty(_collectionSettings.Language3Iso639Code))
            {
                _language3Name.Text          = "--";
                _removeLanguage3Link.Visible = false;
                _language3FontLabel.Visible  = false;
                _fontComboLanguage3.Visible  = false;
                _fontSettings3Link.Visible   = false;
                _changeLanguage3Link.Text    = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.SetThirdLanguageLink", "Set...", "If there is no third language specified, the link changes to this.");
            }
            else
            {
                lang3UiName                  = _collectionSettings.GetLanguage3Name(LocalizationManager.UILanguageId);
                _language3Name.Text          = string.Format("{0} ({1})", lang3UiName, _collectionSettings.Language3Iso639Code);
                _language3FontLabel.Text     = string.Format(defaultFontText, lang3UiName);
                _removeLanguage3Link.Visible = true;
                _language3FontLabel.Visible  = true;
                _fontComboLanguage3.Visible  = true;
                _fontSettings3Link.Visible   = true;
                _changeLanguage3Link.Text    = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.ChangeLanguageLink", "Change...");
            }

            _restartReminder.Visible = AnyReasonToRestart();
            _okButton.Text           = AnyReasonToRestart() ? LocalizationManager.GetString("CollectionSettingsDialog.Restart", "Restart", "If you make certain changes in the settings dialog, the OK button changes to this.") : LocalizationManager.GetString("Common.OKButton", "&OK");
        }
Ejemplo n.º 5
0
        private void UpdateDisplay()
        {
            string defaultFontText =
                LocalizationManager.GetString("CollectionSettingsDialog.BookMakingTab.DefaultFontFor", "Default Font for {0}", "{0} is a language name.");
            var lang1UiName = _collectionSettings.GetLanguage1Name(LocalizationManager.UILanguageId);
            var lang2UiName = _collectionSettings.GetLanguage2Name(LocalizationManager.UILanguageId);

            _language1Name.Text      = string.Format("{0} ({1})", lang1UiName, _collectionSettings.Language1Iso639Code);
            _language2Name.Text      = string.Format("{0} ({1})", lang2UiName, _collectionSettings.Language2Iso639Code);
            _language1FontLabel.Text = string.Format(defaultFontText, lang1UiName);
            _language2FontLabel.Text = string.Format(defaultFontText, lang2UiName);

            var lang3UiName = string.Empty;

            if (string.IsNullOrEmpty(_collectionSettings.Language3Iso639Code))
            {
                _language3Name.Text           = "--";
                _removeLanguage3Link.Visible  = false;
                _language3FontLabel.Visible   = false;
                _fontComboLanguage3.Visible   = false;
                _rtlLanguage3CheckBox.Visible = false;
                _changeLanguage3Link.Text     = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.SetThirdLanguageLink", "Set...", "If there is no third language specified, the link changes to this.");
            }
            else
            {
                lang3UiName                   = _collectionSettings.GetLanguage3Name(LocalizationManager.UILanguageId);
                _language3Name.Text           = string.Format("{0} ({1})", lang3UiName, _collectionSettings.Language3Iso639Code);
                _language3FontLabel.Text      = string.Format(defaultFontText, lang3UiName);
                _removeLanguage3Link.Visible  = true;
                _language3FontLabel.Visible   = true;
                _fontComboLanguage3.Visible   = true;
                _rtlLanguage3CheckBox.Visible = true;
                _changeLanguage3Link.Text     = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.ChangeLanguageLink", "Change...");
            }

            _restartReminder.Visible = _restartRequired;
            _okButton.Text           = _restartRequired ? LocalizationManager.GetString("CollectionSettingsDialog.Restart", "Restart", "If you make certain changes in the settings dialog, the OK button changes to this.") : LocalizationManager.GetString("Common.OKButton", "&OK");

            _xmatterPackCombo.Items.Clear();
            _xmatterPackCombo.Items.AddRange(_xmatterPackFinder.All.ToArray());
            _xmatterPackCombo.SelectedItem = _xmatterPackFinder.FindByKey(_collectionSettings.XMatterPackName);
            if (_xmatterPackCombo.SelectedItem == null)             //if something goes wrong
            {
                _xmatterPackCombo.SelectedItem = _xmatterPackFinder.FactoryDefault;
            }
        }
Ejemplo n.º 6
0
        private static DataSet GatherDataItemsFromCollectionSettings(CollectionSettings collectionSettings)
        {
            var data = new DataSet();

            data.WritingSystemAliases.Add("N1", collectionSettings.Language2Iso639Code);
            data.WritingSystemAliases.Add("N2", collectionSettings.Language3Iso639Code);

            //            if (makeGeneric)
            //            {
            //                data.WritingSystemCodes.Add("V", collectionSettings.Language2Iso639Code);
            //                    //This is not an error; we don't want to use the verncular when we're just previewing a book in a non-verncaulr collection
            //                data.AddGenericLanguageString("iso639Code", collectionSettings.Language1Iso639Code, true);
            //                    //review: maybe this should be, like 'xyz"
            //                data.AddGenericLanguageString("nameOfLanguage", "(Your Language Name)", true);
            //                data.AddGenericLanguageString("nameOfNationalLanguage1", "(Region Lang)", true);
            //                data.AddGenericLanguageString("nameOfNationalLanguage2", "(National Lang)", true);
            //                data.AddGenericLanguageString("country", "Your Country", true);
            //                data.AddGenericLanguageString("province", "Your Province", true);
            //                data.AddGenericLanguageString("district", "Your District", true);
            //                data.AddGenericLanguageString("languageLocation", "(Language Location)", true);
            //            }
            //            else
            {
                data.WritingSystemAliases.Add("V", collectionSettings.Language1Iso639Code);
                data.AddLanguageString("nameOfLanguage", collectionSettings.Language1Name, "*", true);
                data.AddLanguageString("nameOfNationalLanguage1",
                                       collectionSettings.GetLanguage2Name(collectionSettings.Language2Iso639Code), "*", true);
                data.AddLanguageString("nameOfNationalLanguage2",
                                       collectionSettings.GetLanguage3Name(collectionSettings.Language2Iso639Code), "*", true);
                data.UpdateGenericLanguageString("iso639Code", collectionSettings.Language1Iso639Code, true);
                data.UpdateGenericLanguageString("country", collectionSettings.Country, true);
                data.UpdateGenericLanguageString("province", collectionSettings.Province, true);
                data.UpdateGenericLanguageString("district", collectionSettings.District, true);
                string location = "";
                if (!String.IsNullOrEmpty(collectionSettings.District))
                    location += collectionSettings.District + @", ";
                if (!String.IsNullOrEmpty(collectionSettings.Province))
                    location += collectionSettings.Province;

                location = location.TrimEnd(new[] {' '}).TrimEnd(new[] {','});

                if (!String.IsNullOrEmpty(collectionSettings.Country))
                {
                    location += "<br/>" + collectionSettings.Country;
                }

                data.UpdateGenericLanguageString("languageLocation", location, true);
            }
            return data;
        }