c# - Localization of data annotations in separate class library -
we trying implement localization our domain models existing in separate class library project within our solution. however, not able working our models data annotation attributes doesn't translated @ all.
project structure
- solution
- web project
- resource folder (contains .resx files. ex. app.en.resx) works fine
- class library
- domain models
- resource folder (contains .resx files. ex. app.en.resx) doesn't work
- web project
startup.cs
services.addmvc() .addviewlocalization(languageviewlocationexpanderformat.suffix) .adddataannotationslocalization();
note
localization works within web project, e.g translates views, controllers. however, doesn't work when try translate models exists in separate project.
// regards
there no support translate data annotations, views, controller etc exists in separate project without implementing yourself.
the solution write own custom implementation using istringlocalizer, istringlocalizerfactory , register in startup.cs. see how stringlocalizer/factory works.
fyi: aspnet team working on localizer aware of , working on solution support in future. see aspnet/localization
Comments
Post a Comment