eShopOnContainers icon indicating copy to clipboard operation
eShopOnContainers copied to clipboard

Question: Catalog localization

Open NullQubits opened this issue 7 years ago • 2 comments

Hi,

I have a quick question regarding localization. What approach would be best if you had to localize the catalog items (name, description)? Assume that a new CatalogItemDto type is created - this is needed because the controller can no longer return the CatalogItem as is:

Approach 1: Include all translations in the CatalogItem entity. For example, change from String type to LocalizedString that is essentially a Locale<->String map. This would mean that all translations would be stored in db and would be loaded as part of CatalogItem. The controller would get the correct translation and populate the CatalogItemDto accordingly.

Approach 2: CatalogItem would hold the strings in a default locale (en_us). For other locales, the controller will be translating the strings and populating the CatalogItemDto type with the translated string from a .resx file.

Thanks!

NullQubits avatar Mar 10 '19 12:03 NullQubits

No for "Aprpoach 2": .resx files should be used for app's internal strings, basically for static strings not usually updated by business people, such as strings needed for exception descriptions. etc.

Yes for "Approach 1": In the case of the Catalog microservice, that's dealing with "Business/Domain data" related to product's info in this case, so it should follow the same approach than the current approach which is database-based using the entities.

In a multi-lingual system based on a database, you can have several approaches:

  • Fixed number of languages, for instance, EN, ES. You can simply put those columns in the regular SQL table and get one or the other depending on the context.
  • If you have a dynamic number of languages, meaning the number of languages can grow in the future an approach you can do for all names and descriptions in regular tables is to set them as IDs. Then you can have a separate table per entity with all the translations based on key ID+LangID. Note that since you will be joining on every query, this will impact the performance in some degree, so this is usually a good approach unless your data is really huge.

CESARDELATORRE avatar Mar 10 '19 18:03 CESARDELATORRE

Thank you for your insights, much appreciated!

NullQubits avatar Mar 10 '19 19:03 NullQubits