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

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

Popular posts from this blog

Lists in Python -

android - can not access to progress bar in an other activity -

html - Not able to access next element of an array javascript -