✅ Software architecture for front-end translations
I've an .NET 7 Blazor WebAssembly Hosted web application meant to be deployed in a industrial environment local network and to be used by as few as 5 users simultaneously.
Since at the factory there can be workers speaking different languages, and since we can connect via VPN for maintenance, I need to include a translation mechanism, which should involve all the front-end writings.
As of now I've setup some .cs files containing constants fields representing symbols. Example:
Then, in the database I'll have a "transl" table structured like this
And so on.
When an use launch the blazor application, blazor could
1) Retrieve from back-end translations for all the symbols defined in the web application (larger loading time at startup, larger memory usage, lower latency when navigating to another page of the application since no need to request translation for that specific page)
2) Retrieve from back-end translations for the symbols of a given page (maybe I should have a "page" table (representing a Blazor page) and an M-to-M relationship between pages and symbols.
What do you think of this approach?
What bothers me of this approach is to have the symbols hard-coded in the program. I'm not sure if that's acceptable or not.
4 Replies
Why not use the built-in tools, rather than rolling your own? https://learn.microsoft.com/en-us/aspnet/core/blazor/globalization-localization?view=aspnetcore-7.0&pivots=server
ASP.NET Core Blazor globalization and localization
Learn how to render globalized and localized content to users in different cultures and languages.
Because I like to be in control 😛 . But if you say there is a good tool already in place, I'll take a look at that, that is probably better than mine, thanks!
I was able to setup a translation system based on your suggestions. It is actually much simpler than mine to work with and mantain! thank you very much for encouraging me to make the right thing 👍
Awesome!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.