コード例 #1
0
        public string GetTextForKey(StringToken key)
        {
            var localizationKey = key.ToLocalizationKey();

            return(_localeCache
                   .Retrieve(localizationKey, () => _missingHandler.FindMissingText(key, _localeCache.Culture)));
        }
コード例 #2
0
        private TextAndCulture FindTextViaHierarchy(StringToken token, CultureInfo culture)
        {
            var text = _localeCache[culture].Get(token.ToLocalizationKey(), () =>
            {
                if (culture.Parent == CultureInfo.InvariantCulture || culture == culture.Parent)
                {
                    return(_missingHandler.FindMissingText(token, culture));
                }
                return(null);
            });

            if (text == null && (culture.Parent != CultureInfo.InvariantCulture && culture != culture.Parent))
            {
                return(FindTextViaHierarchy(token, culture.Parent));
            }

            return(new TextAndCulture(text, culture));
        }