0

I can't find an answer anywhere really so thought I would post a question about it.

I have followed this tutorial ASP.NET MVC 5 Internationalization · How to Store Strings in a Database or Xml

Now that is fine and all, I can get it to work.

The question now is, how to properly incorporate that into the Onion Architecture.

The tutorial has a Resource Project. Is that still valid or can that be abstracted out?

There is just not a good tutorial on how to incorporate internationalization into the Onion Architecture.

What I have so far is:

  • Database Table (Resource) which holds {Name, Culture, Type, Value}
  • Entity called Resource
  • Interface called 'IResourceRepository` (GetResources(), GetResource(Culture,Name))
  • I have a Service Interface and a Service which also has the same methods as the Repository to get me the resource.

It's my first Time setting up a brand new web application, and only recently learned about the Onion Architecture. Any Help will be very much appreciated.

Update

Here is my partial attempt.

Correct me If i'm wrong please.

  • App.Domain.Entities
    • Resource.cs (name, culture, type, value)
  • App.Domain.Interfaces
    • IResourceRepository.cs (GetResources(), GetResource(Culture, Name))
  • App.Infrastructure.Data
    • ResourceRepository.cs (GetResources(), GetResource(Culture, Name))
  • App.Services.Interfaces
    • IResourceService.cs (object GetResource(Culture, Name))
  • App.Web.UI.Services
    • BaseResourceService.cs (Implements IResourceService.cs)
    • ResourceService.cs (Extends BaseResourceService.cs)

This is how for I got so far. So Resource contains a whole bunch of resources for different cultures.

Pretty sure 'n have done something wrong tho.

Shane van Wyk
  • 1,870
  • 1
  • 26
  • 62
  • Do any of your domain services need `ResourceEntry`? If not, everything should move to the `Infrastructure` layer of your Onion architecture. – MaxSC Dec 23 '14 at 09:46
  • 'Domain Services' ? Not sure what you mean. It basically is a whole lot of resources stored in the database, then i retrieve it and set properties in the UI based on the Culture selected and Property Name available to internationalize. please wee update to question, that is what I have attempted, any feedback / alternative solution will be much appreciated – Shane van Wyk Dec 23 '14 at 10:54
  • Domain services are what your business is all about. I mean, if the business of your application is to deal with Resources, then all the business logic should be coded in the Doamin layer. That means that your `App.Services.Interfaces` should be in the Domain layer and its implementation as well! – MaxSC Dec 23 '14 at 11:12
  • An example of what the application can do is. Add a new user to the system. But i want to provide the ability to do that in a number of cultures. so I save all those cultures in the resource table/entity. I use the repo and its interface to pull the data out of the database. I use the service and it's interface deal with caching and validation of the resource. The service gets injected into the UI layer. Repo gets injected into the service layer. I followed this architecture, well hope I did. https://www.develop.com/onionarchitecture – Shane van Wyk Dec 23 '14 at 11:36
  • So you're application business seems to be user management, not dealing with resoources. Your business code should be about user management, right?. The question is: do you need to access resources while, let's say, instering a new user in the system? You somehow answered that question saying that your `IResourceService` is implemented by the UI layer. From my point of view, all the resources related code should be inside the `Infrastrucure` layer, not in the `Domain`. Make sense? – MaxSC Dec 23 '14 at 14:05

0 Answers0