AspNetCoreLocalization
AspNetCoreLocalization copied to clipboard
Why stringLocalizer arguments are not used
It seems that second version of _localizer["Thing {jep}", jep] is not using arguments at all. https://github.com/damienbod/AspNetCoreLocalization/blob/master/src/Localization.SqlLocalizer/DbStringLocalizer/SqlStringLocalizer.cs#L36 Is there something I need to know about C# or is this just in todo phase. I believe that there should be few more lines in that method like this.
var localicedString = this[name];
return new LocalizedString(name, String.Format(localicedString.Value, arguments), localicedString.ResourceNotFound);
will be released in next version
We're in April 2021, three versions later, but this issue still hasn't been fixed. Is there any chance this will get fixed soon ?
Hi @daniel-jann I'll look at this again. Maybe if you know how to fix it, you could do a PR?
I don't have so much time at the moment
Greetings Damien
https://github.com/damienbod/AspNetCoreLocalization/blob/a362dc73be13cdfb2ee83bd1a8fa9b440ea00e74/src/Localization.SqlLocalizer/DbStringLocalizer/SqlStringLocalizer.cs#L41
parameters work as follows
using System.Linq;
public LocalizedString this[string name, params object[] arguments]
{
get
{
var localizedString = this[name];
return new LocalizedString(name, String.Format(localizedString.Value, arguments.Select(x => x.ToString()).ToArray()), localizedString.ResourceNotFound);
}
}
new LocalizationRecord(){ Key="RequiredError", ResourceKey="global", Text="The {0} field is required.", LocalizationCulture="en-GB" },
new LocalizationRecord(){ Key="Name", ResourceKey="global", Text="Name", LocalizationCulture="en-GB" },
[Required(ErrorMessage = "RequiredError")]
[Display(Name = "Name")]
public string Name { get; set; }