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

            tag = tag.ToUpper();

            var pagePointer =
                this.localizationLanguageResources.page.FirstOrDefault(p => p.name.Equals(this.currentPage));

            LanguageResourcesPageResource pageResource = null;

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

            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>
        /// Gets the hours offset.
        /// </summary>
        /// <param name="languageResource">The resource.</param>
        /// <returns>
        /// The get hours offset.
        /// </returns>
        public static decimal GetHoursOffset(this LanguageResourcesPageResource languageResource)
        {
            // calculate hours -- can use prefix of either UTC or GMT...
            decimal hours;

            try
            {
                hours = languageResource.tag.Replace("UTC", string.Empty).Replace("GMT", string.Empty).ToType <decimal>();
            }
            catch (FormatException)
            {
                hours =
                    languageResource.tag.Replace(".", ",")
                    .Replace("UTC", string.Empty)
                    .Replace("GMT", string.Empty)
                    .ToType <decimal>();
            }

            return(hours);
        }