Esempio n. 1
0
 /// <summary>
 /// Creates all TranlatorItems with the state untranslated
 /// </summary>
 private void DetermineUntranslated(StringArray stringsTranslated, StringArray stringsOriginal)
 {
     foreach (StringItem item in stringsOriginal.GetStringsNotIn(stringsTranslated))
     {
         StringItem itemUntranslated = new StringItem(item);
         itemUntranslated.Text = "";
         Add(new TranslatorItem(itemUntranslated, item, TranslationState.Untranslated));
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Creates all TranlatorItems with the state translated
 /// </summary>
 private void DetermineTranslated(StringArray stringsTranslated, StringArray stringsOriginal)
 {
     foreach (StringItem item in stringsOriginal)
     {
         StringItem itemTranslated = null;
         if (stringsTranslated.GetStringById(item.Id, ref itemTranslated))
         {
             Add(new TranslatorItem(itemTranslated, item, TranslationState.Translated));
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Returns a string with a certain id
        /// </summary>
        public bool GetStringById(long id, ref StringItem item)
        {
            if (!stringsMap.Contains(id))
            {
                item = null;
                return(false);
            }

            item = (StringItem)stringsMap[id];

            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Add a StringItem to the StringArray
        /// </summary>
        public void Add(StringItem item)
        {
            try
            {
                stringsMap.Add(item.Id, item);
            }
            catch (ArgumentException e)
            {
                throw new TranslatorException("The string with the id " + item.Id.ToString() + " appears more then once in this file.", e);
            }

            strings.Add(item);
        }
Esempio n. 5
0
        /// <summary>
        /// Add a StringItem to the StringArray
        /// </summary>
        public void Add(StringItem item)
        {
            try
            {
                stringsMap.Add(item.Id, item);
            }
            catch (ArgumentException e)
            {
                throw new TranslatorException("The string with the id " + item.Id.ToString() + " appears more then once in this file.", e);
            }

            strings.Add(item);
        }
Esempio n. 6
0
        /// <summary>
        /// Returns the ids of all changed strings
        /// of arr.
        /// </summary>
        public long[] GetStringsChangedIn(StringArray arr)
        {
            ArrayList ret = new ArrayList();

            foreach (StringItem item in strings)
            {
                if (item.Id != 6)               // "XBMC SVN"
                {
                    StringItem stringItem = null;
                    arr.GetStringById(item.Id, ref stringItem);
                    if (stringItem != null && stringItem.Text != item.Text)
                    {
                        ret.Add(item.Id);
                    }
                }
            }

            return((long[])ret.ToArray(typeof(long)));
        }
Esempio n. 7
0
        /// <summary>
        /// Returns a StringArray with all string not in
        /// arr.
        /// </summary>
        public StringArray GetStringsNotIn(StringArray arr)
        {
            StringArray ret = new StringArray();

            foreach (StringItem item in strings)
            {
                if (item.Id != 6)               // "XBMC SVN"
                {
                    StringItem stringItem = null;
                    arr.GetStringById(item.Id, ref stringItem);
                    if (stringItem == null)
                    {
                        ret.Add(item);
                    }
                }
            }

            return(ret);
        }
Esempio n. 8
0
        /// <summary>
        /// Returns a string with a certain id
        /// </summary>
        public bool GetStringById(long id, ref StringItem item)
        {
            if (!stringsMap.Contains(id))
            {
                item=null;
                return false;
            }

            item=(StringItem)stringsMap[id];

            return true;
        }
Esempio n. 9
0
        /// <summary>
        /// Loads a language file by filename
        /// </summary>
        public void Load(string filename)
        {
            XmlTextReader reader=null;

            try
            {
                reader=new XmlTextReader(filename);

                XmlDocument doc=new XmlDocument();
                doc.Load(reader);

                foreach (XmlNode node in doc)
                {
                    if (node.NodeType==XmlNodeType.Comment && node.InnerText.IndexOf("$Revision")>-1)
                    {
                        string comment=node.InnerText;
                        int startPos=comment.IndexOf("$Revision")+10;
                        int endPos=comment.IndexOf("$", startPos);

                        if (endPos>startPos)
                        {
                            string str=comment.Substring(startPos, endPos-startPos);
                            version=Convert.ToDouble(str, System.Globalization.CultureInfo.InvariantCulture);
                        }
                        break;
                    }
                }

                XmlNode root=doc.DocumentElement.SelectSingleNode("/strings");
                if (root==null)
                    throw new TranslatorException(filename+" is not a language file.");

                XmlNodeList list=doc.DocumentElement.SelectNodes("/strings/string");

                if (list.Count>0)
                {
                    foreach (XmlNode node in list)
                    {
                        StringItem item=new StringItem();
                        item.LoadFromXml((XmlElement)node);

                        Add(item);
                    }

                    strings.Sort();
                }
            }
            catch(Exception e)
            {
                throw new TranslatorException("Error loading "+filename, e);
            }
            finally
            {
                if (reader!=null)
                    reader.Close();
            }
        }
Esempio n. 10
0
 public TranslatorItem(StringItem translated, StringItem original, TranslationState state)
 {
     this.translated = translated;
     this.original   = original;
     this.state      = state;
 }
Esempio n. 11
0
 /// <summary>
 /// This function is called if a StringItem has beeen modified
 /// </summary>
 private void StringModified(StringItem item)
 {
     modified=true;
 }
Esempio n. 12
0
 /// <summary>
 /// Creates all TranlatorItems with the state untranslated
 /// </summary>
 private void DetermineUntranslated(StringArray stringsTranslated, StringArray stringsOriginal)
 {
     foreach (StringItem item in stringsOriginal.GetStringsNotIn(stringsTranslated))
     {
         StringItem itemUntranslated=new StringItem(item);
         itemUntranslated.Text="";
         Add(new TranslatorItem(itemUntranslated, item, TranslationState.Untranslated));
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Loads a language file by filename
        /// </summary>
        public void Load(string filename)
        {
            XmlTextReader reader = null;

            try
            {
                reader = new XmlTextReader(filename);

                XmlDocument doc = new XmlDocument();
                doc.Load(reader);

                foreach (XmlNode node in doc)
                {
                    if (node.NodeType == XmlNodeType.Comment && node.InnerText.IndexOf("$Revision") > -1)
                    {
                        string comment  = node.InnerText;
                        int    startPos = comment.IndexOf("$Revision") + 10;
                        int    endPos   = comment.IndexOf("$", startPos);

                        if (endPos > startPos)
                        {
                            string str = comment.Substring(startPos, endPos - startPos);
                            version = Convert.ToDouble(str, System.Globalization.CultureInfo.InvariantCulture);
                        }
                        break;
                    }
                }

                XmlNode root = doc.DocumentElement.SelectSingleNode("/strings");
                if (root == null)
                {
                    throw new TranslatorException(filename + " is not a language file.");
                }

                XmlNodeList list = doc.DocumentElement.SelectNodes("/strings/string");

                if (list.Count > 0)
                {
                    foreach (XmlNode node in list)
                    {
                        StringItem item = new StringItem();
                        item.LoadFromXml((XmlElement)node);

                        Add(item);
                    }

                    strings.Sort();
                }
            }
            catch (Exception e)
            {
                throw new TranslatorException("Error loading " + filename, e);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Esempio n. 14
0
 /// <summary>
 /// This function is called if a StringItem has beeen modified
 /// </summary>
 private void StringModified(StringItem item)
 {
     modified = true;
 }
Esempio n. 15
0
 public StringItem(StringItem right)
 {
     id=right.id;
     Text=right.Text;
 }
Esempio n. 16
0
        public int CompareTo(object obj)
        {
            StringItem right = (StringItem)obj;

            return(Convert.ToInt32(Id) - Convert.ToInt32(right.Id));
        }
Esempio n. 17
0
 public StringItem(StringItem right)
 {
     id   = right.id;
     Text = right.Text;
 }
Esempio n. 18
0
 public TranslatorItem(StringItem translated, StringItem original, TranslationState state)
 {
     this.translated=translated;
     this.original=original;
     this.state=state;
 }
Esempio n. 19
0
		/// <summary>
		/// Is called when the string a ListViewItemString represents is changed
		/// </summary>
		private void StringUpdated(StringItem item)
		{
			SubItems[1].Text=item.Text;
		}