Localization Question using Loc Extension
Posted: 15 Sep 2023, 19:41
Hi,
I've just started using Loc Extension, mostly using the localization sample in the tutorials to guide my progress. A couple questions came up for me:
First, for debugging purposes, I'd like to be able to switch the language being used during runtime. When I do this, none of the existing strings that were displayed using the loc extension change to the new language, but as new screens/pages come in, they are showing the new language. Am I doing something wrong? Or am I missing something? Or is there a way to force the xaml to re-lookup all the strings? It seems like a dependency somewhere hasn't been tripped.
Second, again for debugging purposes, I'd like to be able to reload all the localized text from a file on disk. This changes the iteration time from hours to seconds for someone who is testing localization. However, I'm not quite sure how to do this in XAML. Right now, just like the sample, I'm binding the localized text to a resource dictionary like this:
I have all the keys and the strings. Is there a way for me to dynamically update the resource dictionary? Or, going even further - is there a way for me to just create the localized resource dictionary at runtime and manually bind it to loc extension - and then when I want to change things (either switching languages, or even just updating the strings from a file on disk), I just update the resource dictionary?
it seems like this should be possible, as I can create a resource dictionary using noesis APIs:
https://www.noesisengine.com/docs/Gui.C ... onary.html
I'm just not exactly sure how to bind it to the loc extension. Looking at the docs for loc extension:
https://www.noesisengine.com/docs/App.A ... nsion.html
It seems like I can only bind it to a URI source. But when I open up the source code, it looks like there is a "ResourcesProperty" and I could perhaps just call SetValue() with a resource dictionary directly.
Any advice would be greatly appreciated.
thanks!
sam
I've just started using Loc Extension, mostly using the localization sample in the tutorials to guide my progress. A couple questions came up for me:
First, for debugging purposes, I'd like to be able to switch the language being used during runtime. When I do this, none of the existing strings that were displayed using the loc extension change to the new language, but as new screens/pages come in, they are showing the new language. Am I doing something wrong? Or am I missing something? Or is there a way to force the xaml to re-lookup all the strings? It seems like a dependency somewhere hasn't been tripped.
Second, again for debugging purposes, I'd like to be able to reload all the localized text from a file on disk. This changes the iteration time from hours to seconds for someone who is testing localization. However, I'm not quite sure how to do this in XAML. Right now, just like the sample, I'm binding the localized text to a resource dictionary like this:
Code: Select all
noesis:Loc.Source="{Binding SelectedLanguage.Source}"
it seems like this should be possible, as I can create a resource dictionary using noesis APIs:
https://www.noesisengine.com/docs/Gui.C ... onary.html
I'm just not exactly sure how to bind it to the loc extension. Looking at the docs for loc extension:
https://www.noesisengine.com/docs/App.A ... nsion.html
It seems like I can only bind it to a URI source. But when I open up the source code, it looks like there is a "ResourcesProperty" and I could perhaps just call SetValue() with a resource dictionary directly.
Any advice would be greatly appreciated.
thanks!
sam