0

I am writing a ASP.Net Core 2.2 Web Api and now I got the request to support multiple languages (de, en) for the description of our products. What is the best practice for this scenario?

I now read a lot about resx files and this documentation 2 times: https://learn.microsoft.com/de-de/aspnet/core/fundamentals/localization?view=aspnetcore-2.2, but then I also read this post (https://stackoverflow.com/a/10533904/11049948), which says I should just include multiple columns (for each language) for the descriptions in my database.

Now what is the best practice, to

  1. Store the descriptions in multiple languages

  2. Get the right Description from a request

To clarify the question:

By products are meant usual products (like for example clothes). In the frontend (Angular), Admins should be able to edit/create products => Products are dynamic. I haven't really understood when to use resx files (Only for static content, which is not the case here?). Is it now best practice to have those 2 columns in the Product table: Description_DE, Description_EN? What would I do with more than 2 languages?

I hope this clarifies the question...

Christoph Hummler
  • 971
  • 2
  • 7
  • 20
  • By products, you mean something like items in a shopping cart, for example? – imnotaduck Aug 29 '19 at 10:41
  • Which did you try, where you having problems, where are you stuck and why do you think one is better than the other? Please have a read on [What's On-Topic](https://stackoverflow.com/help/on-topic): _Questions which are too broad, unclear, incomplete or primarily opinion-based may be put on hold by the community until they are improved_ and you are essentially asking for a opinions – Tseng Aug 29 '19 at 10:47
  • I edited the question to clarify the details. – Christoph Hummler Aug 29 '19 at 11:40
  • Store in different table : `Table Description { id_product, id_language, Description, isDefault }` to store multiple description for a product – Jmel Becha Aug 29 '19 at 11:47

1 Answers1

1

You can create a table for the description of products ( instead of a varchar column ).

For the products table :

    |--------------|----------------|------------------------|
    |ProductId     | DescriptionId  |Price                   |
    |--------------|----------------|------------------------|
    |  1           | 20             | 150.00                 |
    |  2           | 20             | 370.00                 |

For the new table of Description:

    |--------------|------------|------------------------|
    |DescriptionId | LanguageId |Label                   |
    |------------- | -----------|------------------------|
    |  20          | 1          | This is English bla bla|
    |  20          | 2          | das ist en deutsch bla |

Language also is a Table .

Using this approach , you can manage many language as you want , and when you want to get the data ,you pass the languageId of the user .

So if you want to get the details of product 1 :

SELECT * from product p 
INNER JOIN Description d 
ON p.descriptionId = d.descriptionId
WHERE p.podouctId = 1 and d.languageId = 2 -- DE Desciption
Zied R.
  • 4,964
  • 2
  • 36
  • 67