{"id":23094928,"url":"https://github.com/aksoftware98/maui-localization-demo","last_synced_at":"2025-04-03T19:23:39.887Z","repository":{"id":106045235,"uuid":"565102264","full_name":"aksoftware98/maui-localization-demo","owner":"aksoftware98","description":"Demo shows how you can use AKSoftware.Localization.MultiLanguages in .NET MAUI before releasing the v6.0 out of it ","archived":false,"fork":false,"pushed_at":"2022-11-12T11:18:43.000Z","size":761,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-09T07:34:15.396Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aksoftware98.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-12T10:53:29.000Z","updated_at":"2023-04-08T06:53:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"fdbbb190-4da3-4b6c-8141-a3d66d5980d5","html_url":"https://github.com/aksoftware98/maui-localization-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aksoftware98%2Fmaui-localization-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aksoftware98%2Fmaui-localization-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aksoftware98%2Fmaui-localization-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aksoftware98%2Fmaui-localization-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aksoftware98","download_url":"https://codeload.github.com/aksoftware98/maui-localization-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247062813,"owners_count":20877334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-16T22:18:47.835Z","updated_at":"2025-04-03T19:23:39.881Z","avatar_url":"https://github.com/aksoftware98.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Locailzation in .NET MAUI Project\nTargetting a wide range of users has never been an easy task, even if your project is working perfectly and accomplishes what it supposed to be doing perfectly, there are some kind of challeneges that you need to tackle before you head internatinally with your piece of software. One of the biggest challenges is basically the langauge that your app is supporting, if you decide to go only with your local language, you are goingto miss a big oppurtunities earning more customers globally in other regions. \nThis is why I have released AKSoftware.Localization.MultiLanguages couple years ago, the task of achieving has always been wasting time and a bit hard, so I decided to make it very simple and straightforward, I started first by targeting Blazor WebAssembly applications, and it got expanded to target more .NET frameworks. \nThe work in progress right now is bring the library with all its power to .NET MAUI so the developers can built multilanguage UI for their mobile and desktop applications \n\n## Version 6.x of AKSoftware.Localization.MultiLanguages \nThe big version is coming and targeting the end of year, which will contain a big list of features and improvments, and most importantly is the support of .NET MAUI native by providing a good mechanism to mention the localized keys in XAML out of the box. \n## How to get it to work for now\nIf you are in a hurry and you want to get started, this little example in this repo, shows you how to get started \n- Install the package from NuGet \n ```\n Install-Package AKSoftware.Localization.MultiLanguages \n ```\n - Add your English language file under the **Resources** folder, create a new folder and give it the name **Languages**, then a new file with the name **en-US.yml**\n ![Languages folder](https://github.com/aksoftware98/maui-localization-demo/blob/main/images/Create%20a%20new%20folder.png?raw=true)\n \n - Populate the file with some keys \n ``` YAML\n HelloWorld: Hello, World\nDotNetBotDescription: Cute dot net bot waving hi to you!\nWelcome: Welcome to Maui Multi Languages\nClickMe: Click me\nSingleButtonClickText: You clicked 1 time\nMultiButtonClickText: You clicked {clicks} times\n```\n - In the properties of the newly created language file, set **Build Action** property of the file to **Embedded resource**\n ![Set Build Action](https://github.com/aksoftware98/maui-localization-demo/blob/main/images/Set%20Action%20Type%20.png?raw=true)\n - If you want to support other languages, you can use the online translator tool [AK MultiLanguages Online Translator](https://akmultilanguages.azrurewebsites.net)\n - Upload the **en-US.yml** file and then download the language file that you want to support, add them in the **Languages** folder and set their **Build Action** to embedded resource\n - Now, you are good to go, navigate to MauiProgram.cs to register the service of the lanaguge and start injecting in your ViewModels and Pages to use it\n - Modify the MauiProgram.cs code to add the namespace of the class and register the service as following \n ``` C#\n using AKSoftware.Localization.MultiLanguages; // Add this namespace\n// Other namespaces goes here\n\nnamespace MauiMultiLanguages;\n\npublic static class MauiProgram\n{\n\tpublic static MauiApp CreateMauiApp()\n\t{\n\t\t// Defualt code to initialize the app and the servcies goes here\t\n\t     ...\n\t     // Register the EmbeddedResourceKeysProvider so you can have access to the ILanguageContainerService\n\t\tbuilder.Services.AddLanguageContainer\u003cEmbeddedResourceKeysProvider\u003e(Assembly.GetExecutingAssembly(), \"Resources.Languages\");\n\n\t\treturn builder.Build();\n\t}\n}\n\n```\n\n- Now, open the code-behind file of the MainPage.xaml and bring the **ILanguageContainerService** from the Dependency Injection container and start using it\n ``` C#\n \tprivate ILanguageContainerService _language;\n    public MainPage()\n    {\n        InitializeComponent();\n    }\n\n    private void OnCounterClicked(object sender, EventArgs e)\n\t{\n        _language = this.Handler.MauiContext.Services.GetService\u003cILanguageContainerService\u003e();\n        count++;\n\n\t\tif (count == 1)\n\t\t\tCounterBtn.Text = _language[\"SingleButtonClickText\"];\n\t\telse\n\t\t\tCounterBtn.Text = _language[\"MultiButtonClickText\", new\n\t\t\t{\n                clicks = count\n\t\t\t}];\n\n\t\tSemanticScreenReader.Announce(CounterBtn.Text);\n\t}\n```\n\nThat's it now you can run the app and get started\n![.NET MAUI fetching keys from localized source](https://github.com/aksoftware98/maui-localization-demo/blob/main/images/MAUI%20Screenshot.png?raw=true)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faksoftware98%2Fmaui-localization-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faksoftware98%2Fmaui-localization-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faksoftware98%2Fmaui-localization-demo/lists"}