Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the localized value for the specified id. If formatForDisplay is true, then
        /// the string will have ampersands and newlines converted so the text is displayed
        /// nicely at runtime.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public string GetValueForExactLangAndId(string langId, string id, bool formatForDisplay)
        {
            var tu = TmxDocument.GetTransUnitForId(id);

            if (tu == null)
            {
                return(null);
            }

            var tuv = tu.GetVariantForLang(langId);

            if (tuv == null)
            {
                return(null);
            }

            var value = tuv.Value;

            if (value == null)
            {
                return(null);
            }

            if (formatForDisplay && s_literalNewline != null)
            {
                value = value.Replace(s_literalNewline, kOSRealNewline);
            }

            if (formatForDisplay && _ampersandReplacement != null)
            {
                value = value.Replace(_ampersandReplacement, "&");
            }

            return(value);
        }
Exemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the category for the specified id.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal LocalizationCategory GetCategory(string id)
        {
            TMXTransUnit tu = TmxDocument.GetTransUnitForId(id);

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

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

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

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

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

            return(LocalizationPriority.NotLocalizable);
        }
Exemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the group for the specified id.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal string GetGroup(string id)
        {
            TMXTransUnit tu = TmxDocument.GetTransUnitForId(id);

            return(tu == null ? null : tu.GetPropValue(kGroupPropTag));
        }
Exemplo n.º 5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the comment for the specified id.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public string GetComment(string id)
        {
            TMXTransUnit tu = TmxDocument.GetTransUnitForId(id);

            return(tu == null || tu.Notes.Count == 0 ? null : tu.Notes[0].Text);
        }