Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why stringLocalizer arguments are not used #60

Open
JanneHarju opened this issue Apr 17, 2019 · 4 comments
Open

Why stringLocalizer arguments are not used #60

JanneHarju opened this issue Apr 17, 2019 · 4 comments
Labels

Comments

@JanneHarju
Copy link

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 damienbod added the bug label Apr 30, 2019
@damienbod
Copy link
Owner

will be released in next version

@daniel-jann
Copy link

daniel-jann commented Apr 15, 2021

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 damienbod reopened this Apr 15, 2021
@damienbod
Copy link
Owner

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

daniel-jann pushed a commit to daniel-jann/AspNetCoreLocalization that referenced this issue Apr 15, 2021
damienbod added a commit that referenced this issue Apr 15, 2021
fix issue #60, use stringLocalizer arguments
@suatsuphi
Copy link

return new LocalizedString(name, String.Format(localizedString.Value, arguments), localizedString.ResourceNotFound);

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants