mrlacey / MauiAppAccelerator

A Visual Studio extension to accelerate the creation of new .NET MAUI apps.
https://marketplace.visualstudio.com/items?itemName=MattLaceyLtd.MauiAppAccelerator
MIT License
326 stars 10 forks source link

Add the ability to include different language files #44

Open mrlacey opened 8 months ago

mrlacey commented 8 months ago

Follow on from #1

When creating a new project, add a way to include additional resource files and specify the culture/identifier for each.

Need to investigate validating acceptable values and avoiding duplicates.

In addition to adding the resource files, the config settings for iOS, macOS, & Windows should also be applied to the project.

Separate, but related: including UI settings to enable switching language in the running app.

Link for reference: https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/localization?view=net-maui-8.0

mrlacey commented 8 months ago

Note this may require adding the ability to have a different version of the project settings that includes some basic localized content, such as the app name.

MXM-7 commented 8 months ago

Will respond here to your message left on the setting Issue:

For other points related to what the addition to the settings page would mean and to clarify some of the above:

The language change would be idealy changed at run time and use default Microsoft Localization library to avoid be dependent to any pluggin that may not be maintened in future.

What do you mean by the "default Microsoft Localization library"?

Sorry I was having in mind .Net Resources based localization

In the example Localization page created via the wizard, it currently shows 3 different ways of localizing the text that is shown in the UI (As a resource, via a markup extension, and via binding) which of these should be used in the generated app? For a feature that only one person has asked for (so far) I'm loath to triple the work involved in creating three different versions and having the user select which one they want.

I think Markup Extension is a good choice (if only one have to be choosen). best compromise and allow change at run time. I hope we are talking about the same thing but it's the second solution described in the blog post : https://vladislavantonyuk.github.io/articles/Localize-.NET-MAUI-application/

So that I'm clear from your comments above, you're not advocating for also changing all the pages that can currently be generated in a new app and making all their content (text) localized. I hope that's the case. (It's a lot less work to not have to change everything that already exists.) It would mean populating the resource files with lots of content that I'd expect most people to have (want?) to delete from the generated app.

Yes that What I meant , Has I see it your tools is an excellent startup for any beginners or even more experienced MAUI user and it's not meant to do all the job for develloper but provied a startup project with no build error that provied the mecanism for localization and necessary file to start coding.

Before attempting to implement a solution to change the language at runtime, note also the warning at https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/localization?view=net-maui-8.0#test-localization

... your app loads the appropriate localized resources on a per-thread basis, based on the culture specified by the CurrentUICulture property. Warning While it's possible to set the value of CurrentUICulture in code, the resulting behavior is inconsistent across platforms so this isn't recommended ...

I saw it , it may be solved in future version or may be using a third party pluggin may solve this. I think comunity tool kit contain some tolles for localization

While other solutions to localizing content do exist, I'm not clear which is the best or most appropriate to include as a default/recommended solution.

I understand I think LocalizationResourceManager.Maui is a very good call if you consider using a third party tool.

Thank you for taking time to respond all my messages really appreciated !