Single item of a languge to be translated. Used in the TranslatorArray.
Inheritance: IComparable
Exemplo n.º 1
0
		public ListViewItemString(TranslatorItem item)
		{
			Text=item.StringTranslated.Id.ToString();
			SubItems.Add(item.StringTranslated.Text);
			SubItems.Add(item.StringOriginal.Text);
			item.StringTranslated.stringUpdated+=new StringItem.StringUpdatedDelegate(StringUpdated);
		}
Exemplo n.º 2
0
        /// <summary>
        /// Returns a TranslatorItem by a certain id
        /// </summary>
        public bool GetItemById(long id, ref TranslatorItem item)
        {
            if (!stringsMap.Contains(id))
            {
                item = null;
                return(false);
            }

            item = (TranslatorItem)stringsMap[id];

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates all TranlatorItems with the state changed.
        /// It also saves the master language history
        /// </summary>
        private void DetermineChanged(StringArray stringsTranslated, StringArray stringsOriginal)
        {
            string filenameSaved = System.Windows.Forms.Application.LocalUserAppDataPath.Substring(0, System.Windows.Forms.Application.LocalUserAppDataPath.LastIndexOf(@"\")) + @"\strings.xml";
            string filenamePrev  = System.Windows.Forms.Application.LocalUserAppDataPath.Substring(0, System.Windows.Forms.Application.LocalUserAppDataPath.LastIndexOf(@"\")) + @"\stringsPrev.xml";

            // No history yet?
            if (!File.Exists(filenameSaved))
            {                   // Copy our master language, to have a history
                File.Copy(Settings.Instance.FilenameOriginal, filenameSaved, true);
                return;
            }

            StringArray stringsSaved = new StringArray();

            stringsSaved.Load(filenameSaved);

            // Check the version of the saved master language
            if (stringsOriginal.Version > stringsSaved.Version)
            {                   // saved is older then our current master language,
                                // update history
                File.Copy(filenameSaved, filenamePrev, true);
                File.Copy(Settings.Instance.FilenameOriginal, filenameSaved, true);
            }
            else if (stringsOriginal.Version < stringsSaved.Version)
            {             // Oh Oh, current master is older then the saved one, thow exception
                throw new TranslatorException("File " + Settings.Instance.FilenameOriginal + " is older then the one last used for this translation.");
            }

            stringsSaved.Clear();

            if (File.Exists(filenamePrev))
            {                   // we need at two file to do the diff
                StringArray stringsPrev = new StringArray();
                stringsPrev.Load(filenamePrev);

                // check for changed items
                foreach (long id in stringsPrev.GetStringsChangedIn(stringsOriginal))
                {
                    TranslatorItem translatorItem = null;
                    if (GetItemById(id, ref translatorItem))
                    {
                        if (translatorItem.StringTranslated.Text != "")
                        {
                            translatorItem.State = TranslationState.Changed;
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        public bool MoveNext()
        {
            if (!enumerator.MoveNext())
            {
                return(false);
            }

            TranslatorItem item = (TranslatorItem)enumerator.Current;

            while (item.State != TranslationState.Translated)
            {
                if (!enumerator.MoveNext())
                {
                    return(false);
                }
                item = (TranslatorItem)enumerator.Current;
            }

            return(true);
        }
Exemplo n.º 5
0
        public int CompareTo(object obj)
        {
            TranslatorItem right = (TranslatorItem)obj;

            return(Convert.ToInt32(StringTranslated.Id) - Convert.ToInt32(right.StringTranslated.Id));
        }
Exemplo n.º 6
0
 /// <summary>
 /// Adds a TranslatorItem to the array.
 /// </summary>
 private void Add(TranslatorItem item)
 {
     strings.Add(item);
     stringsMap.Add(item.StringOriginal.Id, item);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Returns a TranslatorItem by a certain id
        /// </summary>
        public bool GetItemById(long id, ref TranslatorItem item)
        {
            if (!stringsMap.Contains(id))
            {
                item=null;
                return false;
            }

            item=(TranslatorItem)stringsMap[id];

            return true;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Adds a TranslatorItem to the array.
 /// </summary>
 private void Add(TranslatorItem item)
 {
     strings.Add(item);
     stringsMap.Add(item.StringOriginal.Id, item);
 }