Custom localization provider or build on top of ResourceProvider in ASP.NET?

In order to use inline localization (resource provider) in ASP.NET, only translated strings can be processed (see GetString ("key", locale) without any user defined arguments if I read the documentation correctly.

What's better for creating a custom resource provider that can handle arguments like GetString ("key", locale, parameters)? To use this, I change the API which is not appropriate because the ResourceProvider should always be the same developer and the only thing that can / should be different is the backend.

The second alternative I see is to create a new provider that comes from ProviderBase, or perhaps to create a class that has nothing.

What do you think? Should I add methods to the resource provider or create something new?

+1


source to share


1 answer


You can:

a) store the localized strings using placeholders, {0}, {1}, ..., {n}, which will then work with the string. Format () or



b) use your own placeholders ({FirstName}, {LastName}, {JobTitle}, etc.) and then replace them with your own methods with actual values. Translators can move placeholders around (because sentences are structured differently based on language).

I'm not sure what you need the parameters for, but I'm guessing it's about the scenario described in b) above.

+1


source







All Articles