✅ 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:

public string CAMERA_CONNECTION_LOST = "camera_connection_lost"

public string CAMERA_CONNECTION_LOST = "camera_connection_lost"
Then, in the database I'll have a "transl" table structured like this

--------------------------------------------------------
| symbol | lang | translation |
--------------------------------------------------------
| camera_connection_lost | en_us | Connection lost |
| camera_connection_lost | it_it | Connessione persa |

--------------------------------------------------------
| symbol | lang | translation |
--------------------------------------------------------
| camera_connection_lost | en_us | Connection lost |
| camera_connection_lost | it_it | Connessione persa |
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
canton7
canton72y ago
ASP.NET Core Blazor globalization and localization
Learn how to render globalized and localized content to users in different cultures and languages.
alkasel#159
alkasel#1592y ago
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 👍
canton7
canton72y ago
Awesome!
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server
More Posts
❔ Help with designing a functional container objectHi, I could use some input for a functional container/result object I'm working on. I want it (the s❔ Enumerable.Current is not null in debug mode but assigns null to variableI know I'm not exactly following the best practices with the reader but this code should work none tJSON Array to build a complex object isn't letting me create multiple different properties inside itHi! I'm having an issue serializing a JSON object to create a Microsoft Band WebTile. Here is my cod❔ Proper mocking for Unit Testing (NUnit)```csharp public class TargetServiceSetEndDateAsTwoMonthsOut : PreProcessorAction<CreateTargetServic❔ My code repeats my menu everytime a invalid character is added - i want to display a error messageMy menu works but I want to display a error message if the user enters a invalid character. I was t❔ problem datetime```c EndSeason = 25/11/2022 05:45, ``` ```c public DateTime EndSeason { get; set; } ```❔ Url.ActionLink is generating full URLs, not relative onesI am using `@Url.ActionLink("ActionName", "ControllerName", new { Route = "values" })` in my .cshtmldotnet watch run FileNotFoundException (System.Runtime 7.0)After updating Visual Studio, which installed the .NET 7.0 SDK, I can no longer use `dotnet watch ru❔ system.text.json source generator in net standardis it possible to use stj's source generator inside a net standard project (i dont mind 2.1)? accord❔ Extract PDF SDK logic inside .Net Blazor component not working, but does work with razor pageI'm making use of Adobe Extract PDF SDK in my .Net Blazor app. The SDK logic is inside a Blazor comp