I'm developing a multi culture application with different microservices, The microservices communicate with each others with integrations event, so when a new record is inserted the owner of the data send an integration events on a bus and the other microservices who need that record integrate in their storage.

My question is how to handle the localization of the entries. Should I:

  1. send to every microservices all the translation every time or
  2. the client should call the microservice and the owner of the data to get data and translation or
  3. there should be a microservice that translate everything regardless of the nature of the element (a microservice where I ask for a key and a culture and he give me the translation)?
  • Can you give an example?
    – Rik D
    May 6 '19 at 16:52
  • @Rik D In my environment a Part(entity that will be produced) js handled by the Planning microservice, the execution microservice and the quality microservice. The part has a Code to identify it and has many translations. The code is inserted in the planning microservice and sent to the others to be added in their database when I have to show the data to the user I need to show the correct translation
    – Sethlans
    May 6 '19 at 17:17
  • If I am in the execution application how do I know the correct translation? Should I send it with the code and store in the execution database or should I call the planning microservice? Or should I have another microservice that knows all the translation?
    – Sethlans
    May 6 '19 at 17:19
  • If I understand it correctly there’s a user who enters some fields on a “new part” form for different languages. You store this in the Planning database and send a NewPartCreated event to the bus. I would probably add the translations to this event, so other services can store this info if they require.
    – Rik D
    May 6 '19 at 17:33
  • Yes this is exactly my case and I was wondering if there are a correct way to handle this case or the best way is to send the translation to all microservices that handle the part
    – Sethlans
    May 6 '19 at 18:47

Due to the multitude of formats for localized numbers and dates, my recommendation is to handle that in your UI.

Microservices Should Work With Data

That means you define the one format for every type of data you intend to exchange:

  • Dates will be formatted (example RFC-3339), and don't forget time zones
  • How numbers will be formatted: pick on neutral locale
  • Data Field names
  • Expected value types

The services themselves are blissfully unaware of the concepts of l10n and i18n.

NOTE: one area you may need to actually take the RFC-3066 language specifier for user entered text if you intend to provide machine translations.

Consistent Data Drives Consistent Results

Since the services exchange data using known data formats there isn't any ambiguity over whether the date 01/02/12 is 1 February 2012, 2 December 2001, or 12 January 2002. It also means that you can actually process the data directly. Dates are stored as Dates, integers are stored as integers, etc. There's no translation that has to happen in the back-end.

Translate in the UI

There are a number of i18n and l10n libraries for JavaScript and other platforms. They all use the standards based identifiers to specify the user's language and locale. Often times they are provided by the browser as well.

The answers to your specific questions can fall out from what the library supports and what it doesn't.

  1. Send to microservices every time?
  • Your browser might actually already be sending it anyway with the Accept-Language header.
  • You should only need to do that for specific requests
  1. Client should call microservice and owner of data to get translation?
  • Again, depends on how you store things. Most of your i18n should be available in the client, but user supplied data won't be.
  1. Microservice to translate everything on demand?
  • Might not scale well
  • You can call the Google Translate service to get machine translations of user entered text when it is uploaded

Again, I would look into seeing what can be done in the client, and reserve any special client/server requests to handle user entered data specifically.

  • 2
    The question is more about business related localization; how to handle product names and descriptions in different languages that are used in multiple services. The order confirmation service, invoice service, related product service, etc. all need the localized product info.
    – Rik D
    May 6 '19 at 20:48
  • 1
    Yes it's not a problem of the client or the UI, they are already translated
    – Sethlans
    May 7 '19 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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