[EC-1002] [BEEEP] Add ability to change language in app#2299
Conversation
# Conflicts: # src/App/Resources/AppResources.resx # src/Core/Abstractions/IStateService.cs
| var clearClipboard = await _stateService.GetClearClipboardAsync(); | ||
| ClearClipboardSelectedIndex = ClearClipboardOptions.FindIndex(k => k.Key == clearClipboard); | ||
|
|
||
| var appLocale = _synchronousStorageService.Get<string>(Core.Constants.AppLocaleKey); |
There was a problem hiding this comment.
Using the storage service directly from the app without going through _stateService goes against the pattern established with multi-account support (even for globals). We could add a Synchronous bool to StorageOptions and create a GetDefaultSynchronousStorageOptionsAsync method to StateService to be used from new AppLocale getter/setter methods, lining up nicely with the other app settings. (I'm assuming this value is global since it sounds like Locale must be set on app initialization, so check out GetThemeAsync & SetThemeAsync in StateService for a good global reference)
There was a problem hiding this comment.
I'll make the change, although I think that at some point we should refactor it to have the globals in some other place and leave the StateService for account related stuff only. I also believe the StateService is getting gigantic and has a lot of responsabilities.
…eMediatorService to a new way to interact with the storage. Later the StateService will only interact with this mediator instead of directly with the storage services, with this we have more control inside the mediator and we can have both sync and async methods to interact with storages handled by the mediator
Type of change
Objective
Add ability to change the language from the app. For now it requires app restart to apply the change.
Code changes
SetCulture(...)so that the culture can be from away the class and fixed some caps in the languages (IDK if the others should be in caps or not)IStorageService. This was done to avoid needing async code for setting the culture when the app is loading which caused some race conditions and therefore some strings weren't translated correctly because the strings were being translated before the Culture was actually updated.StorageMediatorOptionsto pass.Localeto here to be alike to other global settings like theming. Additionally, now it uses the aforementioned mediator to interact with the storages. For now, it's only applied toLocalebut afterwards it'll be refactored so that the storage services are removed from here and the mediator is used for everything. Also, marked some methods asObsoleteso the mediator is used in new additional features.StateServiceto get/set the localeScreenshots
Before you submit
dotnet format --verify-no-changes) (required)