コード例 #1
0
ファイル: Localizer.cs プロジェクト: jiangsq123/YAFNET
        /// <summary>
        /// The get text.
        /// </summary>
        /// <param name="tag">
        /// The tag.
        /// </param>
        /// <param name="localizedText">
        /// The localized text.
        /// </param>
        /// <exception cref="Exception">
        /// </exception>
        public void GetText(string tag, out string localizedText)
        {
            // default the out parameters
            localizedText = string.Empty;

            tag = tag.ToUpper();             //ToUpper(this._currentCulture);

            var pagePointer =
                this._localizationLanguageResources.page.FirstOrDefault(p => p.name.Equals(this._currentPage));

            LanuageResourcesPageResource pageResource = null;

            if (pagePointer != null)
            {
                pageResource = pagePointer.Resource.FirstOrDefault(r => r.tag.Equals(tag));
            }

            if (pageResource == null)
            {
                // attempt to find the tag anywhere...
                pageResource =
                    this._localizationLanguageResources.page.SelectMany(p => p.Resource).FirstOrDefault(r => r.tag.Equals(tag));
            }

            if (pageResource != null && pageResource.Value.IsSet())
            {
                localizedText = pageResource.Value;
            }
        }
コード例 #2
0
        /// <summary>
        /// The get hours offset.
        /// </summary>
        /// <param name="lanuageResource">
        /// The resource.
        /// </param>
        /// <returns>
        /// The get hours offset.
        /// </returns>
        public static decimal GetHoursOffset(this LanuageResourcesPageResource lanuageResource)
        {
            // calculate hours -- can use prefix of either UTC or GMT...
            decimal hours = 0;

            try
            {
                hours = Convert.ToDecimal(lanuageResource.tag.Replace("UTC", string.Empty).Replace("GMT", string.Empty));
            }
            catch (FormatException)
            {
                hours =
                    Convert.ToDecimal(lanuageResource.tag.Replace(".", ",").Replace("UTC", string.Empty).Replace("GMT", string.Empty));
            }

            return(hours);
        }