Example #1
0
        /// <summary>
        /// The text.
        /// </summary>
        /// <param name="merchelloContext">
        /// The merchello context.
        /// </param>
        /// <param name="area">
        /// The area.
        /// </param>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        internal static string Text(IMerchelloContext merchelloContext, string area, string key)
        {
            Mandate.ParameterNotNull(merchelloContext, "MerchelloContext");

            if (string.IsNullOrEmpty(area) || string.IsNullOrEmpty(key))
            {
                return(string.Empty);
            }

            var lang = "en";

            try
            {
                lang = MerchelloConfiguration.Current.Section.LogLocalization;
            }
            catch (Exception)
            {
                lang = "en";
            }

            var cacheKey = CacheKeys.GetLocalizationCacheKey(lang);

            var xdoc = XDocument.Parse((string)merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey, () => ui.getLanguageFile(lang).InnerXml), LoadOptions.None);

            var xArea = xdoc.Descendants("area").FirstOrDefault(x => x.Attribute("alias").Value == area);

            if (xArea == null)
            {
                return(string.Empty);
            }

            var xKey = xArea.Descendants("key").FirstOrDefault(x => x.Attribute("alias").Value == key);

            return(xKey == null ? string.Empty : xKey.Value);
        }