コード例 #1
0
        private string TranslateToCulture(LocalizationCode code, CultureInfo culture)
        {
            var specifiedSourceType = code.SourceType;

            if (specifiedSourceType == LocalizationSourceType.Any)
            {
                return(TranslateUsingHighestPrioritySource(code, culture));
            }

            var source = sources.GetByType(specifiedSourceType);

            return(TranslateWithSpecialSource(source, code.TextCode, culture));
        }
コード例 #2
0
        private string TranslateUsingHighestPrioritySource(LocalizationCode code, CultureInfo culture)
        {
            string translation = null;

            foreach (var source in sources.EnumerateByPriority())
            {
                translation = source.FindString(code.TextCode, culture);
                if (translation != null)
                {
                    break;
                }
            }
            if (translation == null)
            {
                throw new TranslationNotFoundException(code.TextCode, culture);
            }
            return(translation);
        }
コード例 #3
0
 public LocalizationString(ILocalizationFactory localizationFactory, LocalizationCode code)
 {
     this.localizationFactory = localizationFactory;
     this.code = code;
 }
コード例 #4
0
        public string GetString(LocalizationCode code, CultureInfo culture = null)
        {
            var definedCulture = GetDefaultCultureIfNotDefined(culture);

            return(TranslateToCulture(code, definedCulture));
        }