damienbod / AspNetCoreLocalization

Localization.SqlLocalizer & ASP.NET Core MVC Localization Examples
http://damienbod.com/2015/10/21/asp-net-5-mvc-6-localization/
MIT License
251 stars 101 forks source link

Why stringLocalizer arguments are not used #60

Open JanneHarju opened 5 years ago

JanneHarju commented 5 years ago

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);
damienbod commented 5 years ago

will be released in next version

daniel-jann commented 3 years ago

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 ?

damienbod commented 3 years ago

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

suatsuphi commented 3 years ago

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; }