5

Imagine a backend service modeled by a hexagonal architecture, where the domain has a class modeling, let us say, a Step of a creative flow that a mobile app will use:

class Step(
    val stepId: String,
    val description: String
)

The description should come to the client translated according to the User preferences. Nope, the client won't explain it. It expects it told already.

Here is the question: how would you model the translation? There are several ways of course, but I want your opinion on it.

For instance: I could set the description with a default language, and then I could perform a translation on the infrastructure level when returning the Step. But this way, I wouldn't make explicit it on a domain level.

3
  • What characteristics do you wish to optimize for? Commented Nov 18, 2019 at 16:06
  • I'd give priority on readibility and make it clear the domain: everybody landing on the project should read the domain and have a good grasp
    – Bertuz
    Commented Nov 18, 2019 at 16:19
  • Of the ways you explored, which one best meets this priority? Commented Nov 18, 2019 at 16:46

1 Answer 1

4

The multilingual aspect is a requirement that should be included in the domain model.

Multilingualism raises a couple of other questions such as for example:

  • are users supposed to maintain data in several languages when they create/update a step ?
  • is one main language mandatory and others optional ?
  • which language to use when the user’s desired language is missing ?
  • are there other areas in which language may matter ? For example, could steps be included in automatic emails to third parties (e.g. subcontractor, customer, ...) who speak another language than the user who is triggering the message ? (i.e. the preferred language would not only have to be managed for the users, but also for other entities).

Typically the multilingual text would be part of an aggregate that includes the step:

  • either the Step would keep the description for the system’s default language and translation in different languages would be maintained in a separate entity.
  • or all the descriptions are extracted from the Step entity and moved into a multilingual StepDescription entity.
  • or you could consider the multilingual descriptions (i.e.language code+text) as a value object owned by the step.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.