Esempio n. 1
0
        private void UpdateTransUnitComment(TransUnit tu, LocalizingInfo locInfo)
        {
            if (locInfo.DiscoveredDynamically && (tu.GetPropValue(LocalizedStringCache.kDiscoveredDyanmically) != "true"))
            {
                tu.AddProp(LocalizedStringCache.kDiscoveredDyanmically, "true");
                _updated = true;
            }

            if ((locInfo.UpdateFields & UpdateFields.Comment) != UpdateFields.Comment)
            {
                return;
            }

            if ((tu.Notes.Count > 0) && (tu.Notes[0].Text == locInfo.Comment))
            {
                return;
            }

            tu.Notes.Clear();
            _updated = true;

            if (!string.IsNullOrEmpty(locInfo.Comment))
            {
                tu.AddNote(locInfo.Comment);
            }
        }
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the category for the specified id.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal LocalizationCategory GetCategory(string id)
        {
            TransUnit tu = TmxDocument.GetTransUnitForId(id);

            if (tu != null)
            {
                string category = tu.GetPropValue(kCategoryPropTag);

                try
                {
                    return((LocalizationCategory)Enum.Parse(typeof(LocalizationCategory), category));
                }
                catch { }
            }

            return(LocalizationCategory.Other);
        }
Esempio n. 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the priority for the specified id.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal LocalizationPriority GetPriority(string id)
        {
            TransUnit tu = TmxDocument.GetTransUnitForId(id);

            if (tu != null)
            {
                string priority = tu.GetPropValue(kPriorityPropTag);

                try
                {
                    return((LocalizationPriority)Enum.Parse(typeof(LocalizationPriority), priority));
                }
                catch { }
            }

            return(LocalizationPriority.NotLocalizable);
        }
Esempio n. 4
0
        ///// ------------------------------------------------------------------------------------
        ///// <summary>
        ///// Saves the cache to the specified file, if the cache is dirty. If the cache is
        ///// dirty and saved, then true is returned. Otherwise, false is returned.
        ///// </summary>
        ///// ------------------------------------------------------------------------------------
        //private bool SaveIfDirty(string tmxFile)
        //{
        //    if (!IsDirty || string.IsNullOrEmpty(tmxFile))
        //        return false;

        //    //_tmxFile = tmxFile;
        //    IsDirty = false;
        //    TmxDocument.Body.TransUnits.Sort(TuComparer);
        //    TmxDocument.Save(tmxFile);
        //    return true;
        //}

        #endregion

        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Compares two translation units for equality.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private static int TuComparer(TransUnit tu1, TransUnit tu2)
        {
            if (tu1 == null && tu2 == null)
            {
                return(0);
            }

            if (tu1 == null)
            {
                return(-1);
            }

            if (tu2 == null)
            {
                return(1);
            }

            string x = tu1.GetPropValue(kGroupPropTag);
            string y = tu2.GetPropValue(kGroupPropTag);

            if (x == y)
            {
                return(String.CompareOrdinal(tu1.Id, tu2.Id));
            }

            if (x == null)
            {
                return(-1);
            }

            if (y == null)
            {
                return(1);
            }

            return(String.CompareOrdinal(x, y));
        }
Esempio n. 5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the group for the specified id.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal string GetGroup(string id)
        {
            TransUnit tu = TmxDocument.GetTransUnitForId(id);

            return(tu == null ? null : tu.GetPropValue(kGroupPropTag));
        }