I'm developing a ASP.NET Core MVC application and need to design Multilanguage values for entities. There is a lot information how to support localization in UI pages using .resx. I'm looking for some common pattern how to support localization for entities (not for static content on web page), that can be edited by user.
Let say there is a simple dictionary in database table with Statuses
Id Name
----------------------------------------------
1 Not processed
2 To be cancelled
3 To be corrected
4 Processed
5 Rejected
User can create a new status or add translation for other language. The question is how to design tables and how to store translations for other languages?
For now I have a few approaches
1) create table Languages
with all supported languages. Create table Translations
Id LanguageId Key Value
------------------------------------------------
1 en NotProcessed Not processed
2 pl NotProcessed Nie przetworzony
3 de NotProcessed Nicht verarbeitet
4 en ToBeCancelled To be cancelled
5 de ToBeCancelled Zu stornieren
the status table will be
Id Name TranslationKey
----------------------------------------------
1 Not processed NotProcessed
2 To be cancelled ToBeCancelled
then using according to language select proper translations that will show to user.
2) do not create Translations table, but add column
Id Name Translations
----------------------------------------------
1 Not processed en:Not processed;pl:Nie przetworzony;de:Nicht verarbeitet
2 To be cancelled en:To be cancelled;de:Zu stornieren
What do you think about it? I don't know how to keep translations for my entities, may be there are some reliable ways. Please suggest.
Aucun commentaire:
Enregistrer un commentaire