Example #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));
        }
Example #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);
        }
Example #3
0
 public LocalizationString(ILocalizationFactory localizationFactory, LocalizationCode code)
 {
     this.localizationFactory = localizationFactory;
     this.code = code;
 }
Example #4
0
        public string GetString(LocalizationCode code, CultureInfo culture = null)
        {
            var definedCulture = GetDefaultCultureIfNotDefined(culture);

            return(TranslateToCulture(code, definedCulture));
        }