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