Reputation: 2387
We have a .NET MAUI Hybrid app that needs translations. The usual way to do this is to use .resx files but based on our requirements they are not good enough.
Architecture:
Our theoretical approach
adhoc download - we dont want translations to be baked into app in build process, but when we edit something (e.g. some typo), client will fetch a new version on his app startup
structure - the final translation JSON has a structure based on Pages and Components. Example:
{ "General":{ "Yes": "Yes", "No": "No", "Cancel": "Cancel" }, "Pages": { "Home": { "Title": "Home", "Statistics": "Statistics" }, "About": { "Title": "About", "Developers": "Developers" } }, "Components":{ "Header": { "Title": "Header", "Back": "Go back" }, "Footer": { "AllRightsReserved": "All rights reserved" } } }
not to do typos on client (when calling localisation dict like L["Pages.Home.Title"]
), we would like to use some class with pre-defined properties duplicating structure of the JSON. Example: In case I have HomePage.razor
I will inject translation service that would contain: _translationService.Translations.Pages.Home.Title
Proposed flow:
HomePage.razor
Questions:
Upvotes: 4
Views: 874
Reputation: 2387
I had a call with one Software architect and he didnt like this JSON idea.
The reason for me to reinvent the wheel was the lack of tools, because simple usage of .resx
file is PITA.
I found that MS created some tool called Microsoft multilingual toolkit
that should simplify it, but from a few videos I have seen, it looks horrible. On the other hand I got a recommendation for a tool called ResXManager. This tool was the missing part in our workflow.
So our new translation workflow is split into 2 parts:
.resx
file. (still we have to redeploy API to make them available).Summary:
ResXManager
into our flow, we would have to download translations locally, do changes and uplaod them again because the ResXManager is just desktop app.I will update this answer in case we found some flow improvements.
Upvotes: 0
Reputation: 3907
One of the very first things, that I have done about localization, was something very similar to this.
XML file, containing serialized dictionary, saved on Windows Mobile device, with code using NET Compact Framework 2.0.
It works. And this is the only good thing I can say about it.
You see, localization is not just some key-value pairs, that you store somewhere. Just because you see "Hallo" instead of "Hello", it does not mean that your app is now perfectly fit for German people.
At some point, I started to stick to what is generally used, working stable and easy to implement.
You are planning to do the opposite.
(This is opinion based, but your question leads that way anyway)
Upvotes: 2