Erweiterungsmethode hinzugefügt, um alle lokalisierten Zeichenfolgen im String-Localizer in ein Wörterbuch umzuwandeln.

This commit is contained in:
Developer 02 2024-05-31 09:31:59 +02:00
parent 5f84f6bcab
commit 401e742ea3

View File

@ -55,5 +55,12 @@ namespace DigitalData.Core.API
app.UseRequestLocalization(options);
return app;
}
/// <summary>
/// Converts all localized strings to a dictionary.
/// </summary>
/// <param name="localizer">The <see cref="IStringLocalizer"/> instance containing the localized strings.</param>
/// <returns>A dictionary containing all localized strings, where the key is the name of the string and the value is the localized value.</returns>
public static Dictionary<string, string> ToDictionary(this IStringLocalizer localizer) => localizer.GetAllStrings().ToDictionary(ls => ls.Name, ls => ls.Value);
}
}