Rename "ancestor" to "parent" on loc APIs
This commit is contained in:
parent
b041a07652
commit
f7f8d9b9eb
|
|
@ -137,7 +137,7 @@ namespace Microsoft.AspNet.Localization
|
|||
private static CultureInfo GetCultureInfo(
|
||||
IList<string> cultureNames,
|
||||
IList<CultureInfo> supportedCultures,
|
||||
bool fallbackToAncestorCulture)
|
||||
bool fallbackToParentCultures)
|
||||
{
|
||||
foreach (var cultureName in cultureNames)
|
||||
{
|
||||
|
|
@ -145,7 +145,7 @@ namespace Microsoft.AspNet.Localization
|
|||
// the CultureInfo ctor
|
||||
if (cultureName != null)
|
||||
{
|
||||
var cultureInfo = GetCultureInfo(cultureName, supportedCultures, fallbackToAncestorCulture, currentDepth: 0);
|
||||
var cultureInfo = GetCultureInfo(cultureName, supportedCultures, fallbackToParentCultures, currentDepth: 0);
|
||||
if (cultureInfo != null)
|
||||
{
|
||||
return cultureInfo;
|
||||
|
|
@ -159,12 +159,12 @@ namespace Microsoft.AspNet.Localization
|
|||
private static CultureInfo GetCultureInfo(
|
||||
string cultureName,
|
||||
IList<CultureInfo> supportedCultures,
|
||||
bool fallbackToAncestorCulture,
|
||||
bool fallbackToParentCultures,
|
||||
int currentDepth)
|
||||
{
|
||||
var culture = CultureInfoCache.GetCultureInfo(cultureName, supportedCultures);
|
||||
|
||||
if (culture == null && fallbackToAncestorCulture && currentDepth < MaxCultureFallbackDepth)
|
||||
if (culture == null && fallbackToParentCultures && currentDepth < MaxCultureFallbackDepth)
|
||||
{
|
||||
var lastIndexOfHyphen = cultureName.LastIndexOf('-');
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ namespace Microsoft.AspNet.Localization
|
|||
// Trim the trailing section from the culture name, e.g. "fr-FR" becomes "fr"
|
||||
var parentCultureName = cultureName.Substring(0, lastIndexOfHyphen);
|
||||
|
||||
culture = GetCultureInfo(parentCultureName, supportedCultures, fallbackToAncestorCulture, currentDepth + 1);
|
||||
culture = GetCultureInfo(parentCultureName, supportedCultures, fallbackToParentCultures, currentDepth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,12 +29,11 @@ namespace Microsoft.Extensions.Localization
|
|||
/// <summary>
|
||||
/// Gets all string resources.
|
||||
/// </summary>
|
||||
/// <param name="includeAncestorCultures">
|
||||
/// A <see cref="System.Boolean"/> indicating whether to include
|
||||
/// strings from ancestor cultures.
|
||||
/// <param name="includeParentCultures">
|
||||
/// A <see cref="System.Boolean"/> indicating whether to include strings from parent cultures.
|
||||
/// </param>
|
||||
/// <returns>The strings.</returns>
|
||||
IEnumerable<LocalizedString> GetAllStrings(bool includeAncestorCultures);
|
||||
IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ResourceManagerStringLocalizer"/> for a specific <see cref="CultureInfo"/>.
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.Extensions.Localization
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all string resources including those for ancestor cultures.
|
||||
/// Gets all string resources including those for parent cultures.
|
||||
/// </summary>
|
||||
/// <param name="stringLocalizer">The <see cref="IStringLocalizer"/>.</param>
|
||||
/// <returns>The string resources.</returns>
|
||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.Extensions.Localization
|
|||
throw new ArgumentNullException(nameof(stringLocalizer));
|
||||
}
|
||||
|
||||
return stringLocalizer.GetAllStrings(includeAncestorCultures: true);
|
||||
return stringLocalizer.GetAllStrings(includeParentCultures: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ namespace Microsoft.Extensions.Localization
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<LocalizedString> GetAllStrings(bool includeAncestorCultures) =>
|
||||
_localizer.GetAllStrings(includeAncestorCultures);
|
||||
public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures) =>
|
||||
_localizer.GetAllStrings(includeParentCultures);
|
||||
}
|
||||
}
|
||||
|
|
@ -133,23 +133,23 @@ namespace Microsoft.Extensions.Localization
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual IEnumerable<LocalizedString> GetAllStrings(bool includeAncestorCultures) =>
|
||||
GetAllStrings(includeAncestorCultures, CultureInfo.CurrentUICulture);
|
||||
public virtual IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures) =>
|
||||
GetAllStrings(includeParentCultures, CultureInfo.CurrentUICulture);
|
||||
|
||||
/// <summary>
|
||||
/// Returns all strings in the specified culture.
|
||||
/// </summary>
|
||||
/// <param name="includeAncestorCultures"></param>
|
||||
/// <param name="includeParentCultures"></param>
|
||||
/// <param name="culture">The <see cref="CultureInfo"/> to get strings for.</param>
|
||||
/// <returns>The strings.</returns>
|
||||
protected IEnumerable<LocalizedString> GetAllStrings(bool includeAncestorCultures, CultureInfo culture)
|
||||
protected IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures, CultureInfo culture)
|
||||
{
|
||||
if (culture == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(culture));
|
||||
}
|
||||
|
||||
var resourceNames = includeAncestorCultures
|
||||
var resourceNames = includeParentCultures
|
||||
? GetResourceNamesFromCultureHierarchy(culture)
|
||||
: GetResourceNamesForCulture(culture);
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace Microsoft.Extensions.Localization
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<LocalizedString> GetAllStrings(bool includeAncestorCultures) =>
|
||||
GetAllStrings(includeAncestorCultures, _culture);
|
||||
public override IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures) =>
|
||||
GetAllStrings(includeParentCultures, _culture);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue