Esempio n. 1
0
        public void LanguageStringComparer_CorrectlyComparesLanguageStrings()
        {
            const string firstValue  = "Value 1";
            const string frenchValue = "This is the french value.";

            LanguageString ls1 = new LanguageString {
                Iso3LanguageId = "eng", Value = firstValue
            };
            LanguageString ls2 = new LanguageString {
                Iso3LanguageId = "eng", Value = "This is the second value."
            };
            LanguageString ls3 = new LanguageString {
                Iso3LanguageId = "fra", Value = frenchValue
            };

            LanguageStringCollection hs = new LanguageStringCollection();

            var first  = hs.Add(ls1);             // this one should be added
            var second = hs.Add(ls2);             // this one should not be added, it is a duplicate
            var third  = hs.Add(ls3);             // this one should be added

            Assert.IsTrue(first);
            Assert.IsFalse(second);
            Assert.IsTrue(third);
            Assert.AreEqual(2, hs.Count);
            Assert.AreEqual(firstValue, hs.First(ls => ls.Iso3LanguageId == "eng").Value);
            Assert.AreEqual(frenchValue, hs.First(ls => ls.Iso3LanguageId == "fra").Value);
        }
        private void UnpublishCameraCallback(object sender, AsyncWorkerCallbackEventArgs <bool> args)
        {
            bool result = CheckAsyncWorkerCallback <bool>(sender, args, true, LanguageString.Find("PublishMedia_PublishedCameraManagementView_DeletePublishedCameraFailed"));

            Status = ViewModelStatus.Saved;
            Refresh();
        }
        private void SelectFile()
        {
            try
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = LanguageString.Find("DeviceConfiguration_VideoSourceLocalAVIFileView_AVIFileFilter");

                if (!string.IsNullOrEmpty(SelectedFilePath))
                {
                    FileInfo info = new FileInfo(SelectedFilePath);
                    dialog.InitialDirectory = info.DirectoryName;
                }
                else
                {
                    dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonVideos);
                }

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    SelectedFilePath = dialog.FileName;
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.Handle(ex);
            }
        }
Esempio n. 4
0
        public bool Equals(ProductRating other)
        {
            var result = PID == other.PID && LanguageString.Equals(other.LanguageString, StringComparison.Ordinal) &&
                         NativeRatings.Equals(other.NativeRatings) && ExternalRatings.Equals(other.ExternalRatings);

            return(result);
        }
Esempio n. 5
0
        protected override void BindCommands()
        {
            RefreshServiceCommand = new RelayCommand(() =>
            {
                ServiceCollection.Clear();
                Status = ViewModelStatus.Initializing;
                Model.GetServices(GetServicesCallback);
            });

            SelectServiceCommand = new RelayCommand(() =>
            {
                if (SelectedService == null)
                {
                    Messenger.Default.Send(new ViewModelMessageBoxMessage(this, LanguageString.Find("PublishMedia_PublishServiceSelectionView_SelectedServiceNull"), ViewModelMessageBoxType.Error));
                    return;
                }

                Messenger.Default.Send(new NotificationMessage <PublishPair>(UIMessageType.PublishMedia_ServiceSelectedEvent, new PublishPair(SelectedService, SelectedCamera)));
            });

            CancelCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(new NotificationMessage(UIMessageType.PublishMedia_CancelSelectServiceEvent));
            });
        }
Esempio n. 6
0
        /// <summary>
        /// Load the English document and cache it in the List of LanguageStrings so it only needs to be read in once.
        /// </summary>
        private static void RefreshStrings()
        {
            if (Utils.IsRunningInVisualStudio())
            {
                return;
            }

            try
            {
                _objDictionary.Clear();
                XmlDocument objEnglishDocument = new XmlDocument();
                string      strFilePath        = Path.Combine(Application.StartupPath, "lang", "en-us.xml");
                objEnglishDocument.Load(strFilePath);
                foreach (XmlNode objNode in objEnglishDocument.SelectNodes("/chummer/strings/string"))
                {
                    LanguageString objString = new LanguageString();
                    objString.Key  = objNode["key"].InnerText;
                    objString.Text = objNode["text"].InnerText;
                    _objDictionary.Add(objNode["key"].InnerText, objNode["text"].InnerText);
                }
                _blnLoaded = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                //TODO this might f**k stuff up, remove before release, or fix?
                //Had obscure bug where this closed visual studio
                MessageBox.Show("Could not load default language file!" + Path.Combine(Application.StartupPath, "lang", "en-us.xml"), "Default Language Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //Application.Exit();
            }
        }
Esempio n. 7
0
        private void DeleteCameraCallback(object sender, AsyncWorkerCallbackEventArgs <bool> args)
        {
            bool result = CheckAsyncWorkerCallback <bool>(sender, args, true, LanguageString.Find("DeviceConfiguration_CameraManagementView_DeleteCameraFailed"));

            Status = ViewModelStatus.Saved;
            Refresh();
        }
Esempio n. 8
0
        /// <summary>
        /// Load the English document and cache it in the List of LanguageStrings so it only needs to be read in once.
        /// </summary>
        private static void RefreshStrings()
        {
            try
            {
                _objDictionary.Clear();
                XmlDocument objEnglishDocument = new XmlDocument();
                string      strFilePath        = Path.Combine(GlobalOptions.ApplicationPath(), "lang");
                strFilePath = Path.Combine(strFilePath, "en-us.xml");
                objEnglishDocument.Load(strFilePath);
                foreach (XmlNode objNode in objEnglishDocument.SelectNodes("/chummer/strings/string"))
                {
                    LanguageString objString = new LanguageString();
                    objString.Key  = objNode["key"].InnerText;
                    objString.Text = objNode["text"].InnerText;
                    _objDictionary.Add(objNode["key"].InnerText, objNode["text"].InnerText);
                }

                if (GlobalOptions.Instance.Language != "en-us")
                {
                    LoadTranslatedString();
                }

                _blnLoaded = true;
            }
            catch
            {
                MessageBox.Show("Could not load default language file!", "Default Language Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string key   = textBoxOcrFixKey.Text.Trim();
            string value = textBoxOcrFixValue.Text.Trim();

            if (key.Length == 0 || value.Length == 0 || key == value)
            {
                return;
            }

            try
            {
                var ci = new CultureInfo(LanguageString.Replace("_", "-"));
                _threeLetterIsoLanguageName = ci.ThreeLetterISOLanguageName;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                return;
            }
            var ocrFixReplaceList = OcrFixReplaceList.FromLanguageId(_threeLetterIsoLanguageName);

            ocrFixReplaceList.AddWordOrPartial(key, value);
            DialogResult = DialogResult.OK;
            NewSource    = key;
            NewTarget    = value;
        }
Esempio n. 10
0
        protected override void BindCommands()
        {
            SearchCameraCommand = new RelayCommand(() =>
            {
                Status = ViewModelStatus.Loading;
                CameraCollection.Clear();
                Model.SearchCameras(SearchCameraText, SearchCamerasCallback);
            });

            RefreshCameraCommand = new RelayCommand(() =>
            {
                SearchCameraText = string.Empty;
                Refresh();
            });

            PublishCameraCommand = new RelayCommand(() =>
            {
                if (SelectedCamera == null)
                {
                    Messenger.Default.Send(new ViewModelMessageBoxMessage(this, LanguageString.Find("PublishMedia_CameraListView_PublishCameraNull"), ViewModelMessageBoxType.Error));
                    return;
                }

                Messenger.Default.Send(new NotificationMessage <Camera>(UIMessageType.PublishMedia_CameraSelectedEvent, SelectedCamera));
            });

            CancelCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(new NotificationMessage(UIMessageType.PublishMedia_CancelSelectCameraEvent));
            });
        }
        public void LoadLanguageFromAssemblyTest()
        {
            string strLanguageFile = string.Empty; // TODO: 初始化为适当的值

            LanguageString.LoadLanguageFromAssembly(strLanguageFile);
            Assert.Inconclusive("无法验证不返回值的方法。");
        }
Esempio n. 12
0
        public static bool?Show(string message, string detail, MessageBoxWindowType windowType, MessageBoxWindowButtonsType buttonType)
        {
            MessageBoxWindow window = new MessageBoxWindow();

            window.Message     = message;
            window.Detail      = detail;
            window.WindowType  = windowType;
            window.ButtonsType = buttonType;

            switch (windowType)
            {
            case MessageBoxWindowType.Information:
                window.Title = LanguageString.Find("Presentation_Windows_MessageBoxWindow_Information");
                break;

            case MessageBoxWindowType.Question:
                window.Title = LanguageString.Find("Presentation_Windows_MessageBoxWindow_Question");
                break;

            case MessageBoxWindowType.Warning:
                window.Title = LanguageString.Find("Presentation_Windows_MessageBoxWindow_Warning");
                break;

            case MessageBoxWindowType.Error:
                window.Title = LanguageString.Find("Presentation_Windows_MessageBoxWindow_Error");
                break;

            default:
                window.Title = LanguageString.Find("Presentation_Windows_MessageBoxWindow_Information");
                break;
            }

            return(window.ShowDialog());
        }
        public void ExceptionStringTest()
        {
            LanguageString          target = new LanguageString(); // TODO: 初始化为适当的值
            LanguageExceptionString actual;

            actual = target.ExceptionString;
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
        private void PublishCameraCallback(object sender, AsyncWorkerCallbackEventArgs <bool> args)
        {
            bool result = CheckAsyncWorkerCallback <bool>(sender, args, true, LanguageString.Find("PublishMedia_PublishedCameraConfigurationView_PublishCameraFailed"));

            Status = ViewModelStatus.Saved;

            Messenger.Default.Send(new NotificationMessage(UIMessageType.PublishMedia_CameraPublishedEvent));
        }
Esempio n. 15
0
        public void SetDefaultLanguageStringTest()
        {
            LanguageString globalString         = null; // TODO: 初始化为适当的值
            LanguageString globalStringExpected = null; // TODO: 初始化为适当的值

            LanguageStringFromAssembly_Accessor.SetDefaultLanguageString(ref globalString);
            Assert.AreEqual(globalStringExpected, globalString);
            Assert.Inconclusive("无法验证不返回值的方法。");
        }
        private void CheckPortAvailableCallback(object sender, AsyncWorkerCallbackEventArgs <bool> e)
        {
            bool result = CheckAsyncWorkerCallback <bool>(sender, e, true, LanguageString.Find("PublishMedia_PublishedCameraConfigurationView_CheckPortAvailableError"));

            Status = ViewModelStatus.Loaded;

            if (result)
            {
                CheckPortAvailableResult = (bool)(e.Data) ? CheckPortAvailableResultResultType.Available : CheckPortAvailableResultResultType.Unavailable;
            }
        }
Esempio n. 17
0
        private void UpdateCameraCallback(object sender, AsyncWorkerCallbackEventArgs <Camera> args)
        {
            bool result = CheckAsyncWorkerCallback <Camera>(sender, args, true, LanguageString.Find("DeviceConfiguration_CameraCreationView_UpdateCameraFailed"));

            Status = ViewModelStatus.Saved;

            if (result)
            {
                Messenger.Default.Send(new NotificationMessage <Camera>(UIMessageType.DeviceConfiguration_CameraUpdatedEvent, args.Data as Camera));
            }
        }
        public void CultureInfoTest()
        {
            LanguageString target   = new LanguageString(); // TODO: 初始化为适当的值
            CultureInfo    expected = null;                 // TODO: 初始化为适当的值
            CultureInfo    actual;

            target.CultureInfo = expected;
            actual             = target.CultureInfo;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Esempio n. 19
0
        public static bool?ShowQuestionYesNo(string message, string detail)
        {
            MessageBoxWindow window = new MessageBoxWindow();

            window.Title       = LanguageString.Find("Presentation_Windows_MessageBoxWindow_Question");
            window.Message     = message;
            window.Detail      = detail;
            window.WindowType  = MessageBoxWindowType.Information;
            window.ButtonsType = MessageBoxWindowButtonsType.YesNo;

            return(window.ShowDialog());
        }
Esempio n. 20
0
        public void LoadLanguageFromAssemblyTest()
        {
            string         strLanguageFile      = string.Empty; // TODO: 初始化为适当的值
            LanguageString globalString         = null;         // TODO: 初始化为适当的值
            LanguageString globalStringExpected = null;         // TODO: 初始化为适当的值
            Assembly       expected             = null;         // TODO: 初始化为适当的值
            Assembly       actual;

            actual = LanguageStringFromAssembly.LoadLanguageFromAssembly(strLanguageFile, ref globalString);
            Assert.AreEqual(globalStringExpected, globalString);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Esempio n. 21
0
        /// <summary>Converts a LanguageString into a Description_Type</summary>
        /// <param name="langString"></param>
        /// <returns></returns>
        public static DescriptionType ToIMDIDescriptionType(this LanguageString langString)
        {
            var desc = new DescriptionType {
                Value = langString.Value
            };

            if (!string.IsNullOrEmpty(langString.Iso3LanguageId))
            {
                desc.LanguageId = LanguageList.FindByISO3Code(langString.Iso3LanguageId).Id;
            }

            return(desc);
        }
Esempio n. 22
0
        /// <summary>Add a description of the package/corpus</summary>
        /// <param name="description"></param>
        public new void AddDescription(LanguageString description)
        {
            // prevent duplicate description
            foreach (var itm in BaseMajorObject.Description)
            {
                if (itm.LanguageId == description.Iso3LanguageId)
                {
                    throw new InvalidOperationException(string.Format("A description for language {0} has already been set", itm.LanguageId));
                }
            }

            BaseMajorObject.Description.Add(description);
        }
Esempio n. 23
0
        private void CheckCameraNameCallback(object sender, AsyncWorkerCallbackEventArgs <bool> e)
        {
            bool result = CheckAsyncWorkerCallback <bool>(sender, e, true, LanguageString.Find("DeviceConfiguration_CameraCreationView_CheckCameraNameError"));

            Status = ViewModelStatus.Loaded;

            if (result)
            {
                CheckCameraNameResult = (bool)(e.Data) ? CheckNameExistedResultType.NotExisted : CheckNameExistedResultType.IsExisted;
            }

            _syncWork.Set(); // 操作已完成
        }
Esempio n. 24
0
        private Instance CreateInstanceFromTemplate(Application appInfo, Instance instanceTemplate, int ownerId, DateTime creationTime, string userId)
        {
            Instance createdInstance = new Instance()
            {
                InstanceOwnerId     = ownerId.ToString(),
                CreatedBy           = userId,
                CreatedDateTime     = creationTime,
                LastChangedBy       = userId,
                LastChangedDateTime = creationTime,
                AppId             = appInfo.Id,
                Org               = appInfo.Org,
                VisibleDateTime   = DateTimeHelper.ConvertToUniversalTime(instanceTemplate.VisibleDateTime),
                DueDateTime       = DateTimeHelper.ConvertToUniversalTime(instanceTemplate.DueDateTime),
                Labels            = instanceTemplate.Labels,
                PresentationField = instanceTemplate.PresentationField,
                InstanceState     = new InstanceState {
                    IsArchived = false, IsDeleted = false, IsMarkedForHardDelete = false
                },
            };

            // copy applications title to presentation field if not set by instance template
            if (createdInstance.PresentationField == null && appInfo.Title != null)
            {
                LanguageString presentation = new LanguageString();

                foreach (KeyValuePair <string, string> title in appInfo.Title)
                {
                    presentation.Add(title.Key, title.Value);
                }

                createdInstance.PresentationField = presentation;
            }

            if (createdInstance.Data == null)
            {
                createdInstance.Data = new List <DataElement>();
            }

            if (instanceTemplate.Process != null)
            {
                createdInstance.Process = instanceTemplate.Process;
            }
            else
            {
                createdInstance.Process = new ProcessState();
            }

            return(createdInstance);
        }
Esempio n. 25
0
        private Camera MakeCheckedCamera()
        {
            if (string.IsNullOrEmpty(CameraName))
            {
                Messenger.Default.Send(new ViewModelMessageBoxMessage(
                                           this, LanguageString.Find("DeviceConfiguration_CameraCreationView_CameraNameNull"), ViewModelMessageBoxType.Error));
                return(null);
            }

            Camera camera = CameraFactory.CreateCamera();

            camera.Name = CameraName;

            return(camera);
        }
Esempio n. 26
0
        public void TestApplicationClient()
        {
            LanguageString title = new LanguageString
            {
                { "nb", "testapplikasjon" },
                { "en", "Test application" },
            };

            Application appMetadata = applicationClient.CreateApplication("test/sailor", title);

            Assert.Equal("test/sailor", appMetadata.Id);

            Application appMetadata2 = applicationClient.GetApplication("test/sailor");

            Assert.Equal(appMetadata.Id, appMetadata2.Id);
        }
        public ScheduleViewModel(Schedule schedule)
        {
            this.schedule = schedule;

            this._title = new LanguageString()
            {
                Strings = schedule.Title
            };
            this._body1 = new LanguageString()
            {
                Strings = schedule.Body1
            };
            this._body2 = new LanguageString()
            {
                Strings = schedule.Body2
            };
        }
Esempio n. 28
0
        public void AddDescription_Add2ForSameLanguage_AddsOnlyTheFirst()
        {
            var desc1 = new LanguageString {
                Iso3LanguageId = "eng", Value = "First description"
            };
            var desc2 = new LanguageString {
                Iso3LanguageId = "eng", Value = "Second description"
            };

            var obj = new Corpus();

            obj.Description.Add(desc1);
            obj.Description.Add(desc2);

            Assert.AreEqual(1, obj.Description.Count);
            Assert.AreEqual("First description", obj.Description.First().Value);
        }
Esempio n. 29
0
        protected void ResourcesGrid_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("EmptyInsert"))
            {
                TextBox nameField  = ResourcesGrid.Controls[0].Controls[0].FindControl("Name") as TextBox;
                TextBox valueField = ResourcesGrid.Controls[0].Controls[0].FindControl("Translation") as TextBox;

                LanguageString languageString = new LanguageString();
                languageString.ResourceName = nameField.Text.Trim();
                languageString.Translation  = valueField.Text.Trim();
                languageString.Language     = _Language;
                languageString.Save();
                ResourcesGrid.DataBind();
                ResourcesGrid.ShowFooter = false;
            }
            else if (e.CommandName.Equals("Insert"))
            {
                TextBox nameField  = ResourcesGrid.FooterRow.FindControl("Name") as TextBox;
                TextBox valueField = ResourcesGrid.FooterRow.FindControl("Translation") as TextBox;


                // check if a resource with same key already exists
                if (AbleContext.Resolve <ILanguageStringRepository>().Load(nameField.Text.Trim()) == null)
                {
                    LanguageString languageString = new LanguageString();
                    languageString.ResourceName = nameField.Text.Trim();
                    languageString.Translation  = valueField.Text.Trim();
                    languageString.Language     = _Language;
                    languageString.Save();
                    ResourcesGrid.DataBind();
                }
                else
                {
                    RequiredFieldValidator NameValidator = ResourcesGrid.FooterRow.FindControl("NameValidator") as RequiredFieldValidator;
                    NameValidator.IsValid      = false;
                    NameValidator.ErrorMessage = "<br/>Name already exists.";
                }
            }
            else if (e.CommandName.Equals("Cancel"))
            {
                ResourcesGrid.ShowFooter = false;
            }
        }
Esempio n. 30
0
        protected void ResourcesGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int            resourceId     = (int)ResourcesGrid.DataKeys[e.RowIndex].Value;
            LanguageString languageString = LanguageStringDataSource.Load(resourceId);

            if (languageString != null)
            {
                GridViewRow row   = (GridViewRow)ResourcesGrid.Rows[e.RowIndex];
                TextBox     name  = (TextBox)row.FindControl("Name");
                TextBox     value = (TextBox)row.FindControl("Translation");

                languageString.ResourceName = name.Text.Trim();
                languageString.Translation  = value.Text.Trim();

                languageString.Save();
            }
            ResourcesGrid.EditIndex = -1;
            e.Cancel = true;
            ResourcesGrid.DataBind();
        }
Esempio n. 31
0
		public void LanguageStringComparer_CorrectlyComparesLanguageStrings()
		{
			const string firstValue = "Value 1";
			const string frenchValue = "This is the french value.";

			LanguageString ls1 = new LanguageString { Iso3LanguageId = "eng", Value = firstValue };
			LanguageString ls2 = new LanguageString { Iso3LanguageId = "eng", Value = "This is the second value." };
			LanguageString ls3 = new LanguageString { Iso3LanguageId = "fra", Value = frenchValue };

			LanguageStringCollection hs = new LanguageStringCollection();

			var first = hs.Add(ls1);  // this one should be added
			var second = hs.Add(ls2); // this one should not be added, it is a duplicate
			var third = hs.Add(ls3);  // this one should be added

			Assert.IsTrue(first);
			Assert.IsFalse(second);
			Assert.IsTrue(third);
			Assert.AreEqual(2, hs.Count);
			Assert.AreEqual(firstValue, hs.First(ls => ls.Iso3LanguageId == "eng").Value);
			Assert.AreEqual(frenchValue, hs.First(ls => ls.Iso3LanguageId == "fra").Value);
		}
Esempio n. 32
0
 /// <summary>
 /// Load the English document and cache it in the List of LanguageStrings so it only needs to be read in once.
 /// </summary>
 private static void RefreshStrings()
 {
     try
     {
         _objDictionary.Clear();
         XmlDocument objEnglishDocument = new XmlDocument();
         string strFilePath = Path.Combine(Environment.CurrentDirectory, "lang", "en-us.xml");
         objEnglishDocument.Load(strFilePath);
         foreach (XmlNode objNode in objEnglishDocument.SelectNodes("/chummer/strings/string"))
         {
             LanguageString objString = new LanguageString();
             objString.Key = objNode["key"].InnerText;
             objString.Text = objNode["text"].InnerText;
             _objDictionary.Add(objNode["key"].InnerText, objNode["text"].InnerText);
         }
         _blnLoaded = true;
     }
     catch
     {
         MessageBox.Show("Could not load default language file!", "Default Language Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Application.Exit();
     }
 }
Esempio n. 33
0
        /// <summary>
        /// Check the Keys in the selected language file against the English version. 
        /// </summary>
        /// <param name="strLanguage">Language to check.</param>
        public void VerifyStrings(string strLanguage)
        {
            // Load the English version.
            List<LanguageString> lstEnglish = new List<LanguageString>();
            XmlDocument objEnglishDocument = new XmlDocument();
            string strFilePath = Path.Combine(Environment.CurrentDirectory, "lang", "en-us.xml");
            objEnglishDocument.Load(strFilePath);
            foreach (XmlNode objNode in objEnglishDocument.SelectNodes("/chummer/strings/string"))
            {
                LanguageString objString = new LanguageString();
                objString.Key = objNode["key"].InnerText;
                objString.Text = objNode["text"].InnerText;
                lstEnglish.Add(objString);
            }

            // Load the selected language version.
            List<LanguageString> lstLanguage = new List<LanguageString>();
            XmlDocument objLanguageDocument = new XmlDocument();
            string strLangPath = Path.Combine(Environment.CurrentDirectory, "lang", strLanguage + ".xml");
            objLanguageDocument.Load(strLangPath);
            foreach (XmlNode objNode in objLanguageDocument.SelectNodes("/chummer/strings/string"))
            {
                LanguageString objString = new LanguageString();
                objString.Key = objNode["key"].InnerText;
                objString.Text = objNode["text"].InnerText;
                lstLanguage.Add(objString);
            }

            string strMessage = "";
            // Check for strings that are in the English file but not in the selected language file.
            foreach (LanguageString objString in lstEnglish)
            {
                LanguageString objFindString = lstLanguage.Find(objItem => objItem.Key == objString.Key);
                if (objFindString == null)
                    strMessage += "\nMissing String: " + objString.Key;
            }
            // Check for strings that are not in the English file but are in the selected language file (someone has put in Keys that they shouldn't have which are ignored).
            foreach (LanguageString objString in lstLanguage)
            {
                LanguageString objFindString = lstEnglish.Find(objItem => objItem.Key == objString.Key);
                if (objFindString == null)
                    strMessage += "\nUnused String: " + objString.Key;
            }

            // Display the message.
            if (strMessage != "")
                MessageBox.Show(strMessage, "Language File Contents", MessageBoxButtons.OK, MessageBoxIcon.Information);
            else
                MessageBox.Show("Language file is OK.", "Language File Contents", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 34
0
		public void AddDescription_Add2ForSameLanguage_AddsOnlyTheFirst()
		{
			var desc1 = new LanguageString { Iso3LanguageId = "eng", Value = "First description"};
			var desc2 = new LanguageString { Iso3LanguageId = "eng", Value = "Second description" };

			var obj = new Corpus();
			obj.Description.Add(desc1);
			obj.Description.Add(desc2);

			Assert.AreEqual(1, obj.Description.Count);
			Assert.AreEqual("First description", obj.Description.First().Value);
		}
Esempio n. 35
0
		/// <remarks/>
		public void AddDescription(LanguageString description)
		{
			Description.Add(description);
		}
Esempio n. 36
0
        /// <summary>
        /// Load the English document and cache it in the List of LanguageStrings so it only needs to be read in once.
        /// </summary>
        private static void RefreshStrings()
        {
            if (Utils.IsRunningInVisualStudio()) return;

            try
            {
                _objDictionary.Clear();
                XmlDocument objEnglishDocument = new XmlDocument();
                string strFilePath = Path.Combine(Application.StartupPath, "lang", "en-us.xml");
                objEnglishDocument.Load(strFilePath);
                foreach (XmlNode objNode in objEnglishDocument.SelectNodes("/chummer/strings/string"))
                {
                    LanguageString objString = new LanguageString();
                    objString.Key = objNode["key"].InnerText;
                    objString.Text = objNode["text"].InnerText;
                    _objDictionary.Add(objNode["key"].InnerText, objNode["text"].InnerText);
                }
                _blnLoaded = true;
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
                //TODO this might f**k stuff up, remove before release, or fix?
                //Had obscure bug where this closed visual studio
                MessageBox.Show("Could not load default language file!" + Path.Combine(Application.StartupPath, "lang", "en-us.xml"), "Default Language Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //Application.Exit();
            }
        }
Esempio n. 37
0
		/// <summary>Add a description of the package/corpus</summary>
		/// <param name="description"></param>
		public new void AddDescription(LanguageString description)
		{
			// prevent duplicate description
			foreach (var itm in BaseMajorObject.Description)
			{
				if (itm.LanguageId == description.Iso3LanguageId)
					throw new InvalidOperationException(string.Format("A description for language {0} has already been set", itm.LanguageId));
			}

			BaseMajorObject.Description.Add(description);
		}
Esempio n. 38
0
 internal static string FormatString(LanguageString stringName, params object[] value)
 {
     return string.Format(m_strings[stringName.ToString()], value);
 }
Esempio n. 39
0
		/// <summary>Add a description of the package/corpus</summary>
		/// <param name="sessionId"></param>
		/// <param name="description"></param>
		public void AddDescription(string sessionId, LanguageString description)
		{
			// prevent duplicate description
			if (_corpus)
			{
				foreach (var sess in Sessions.Where(sess => sess.Name == sessionId))
				{
					sess.AddDescription(description);
				}
			}
			else
			{
				if (BaseMajorObject is Session)
				{
					if (Name == sessionId)
						AddDescription(description);
				}

			}
		}
Esempio n. 40
0
		/// <summary />
		public void AddDescription(LanguageString description)
		{
			throw new NotImplementedException();
		}