Closed linhmc closed 3 years ago
Hi @codingseb
In Loc.cs class I suggest add method.
public void RaiseLanguageChange()
{
TMLanguageChangingEventArgs changingArgs = new TMLanguageChangingEventArgs(currentLanguage, currentLanguage);
TMLanguageChangedEventArgs changedArgs = new TMLanguageChangedEventArgs(currentLanguage, currentLanguage);
CurrentLanguageChanging?.Invoke(this, changingArgs);
if (!changingArgs.Cancel)
{
CurrentLanguageChanged?.Invoke(this, changedArgs);
}
}
Developer can invoke to update language. Please consider.
Hello again @linhmc Yes it's a good idea. Thanks for it.
I will include it in Loc.cs as soon as possible and publish a new CodingSeb.Localization version
Ok I published :
To allow hot reloading of files and implement the method RaiseLanguageChangeEvents
in class Loc
.
I also implemented an example of hot reloading in CodingSeb.Localization.Examples.
See :
<Button x:Name="LanguageChangedRefreshButton"
DockPanel.Dock="Right"
Content="Refresh"
Click="LanguageChangedRefreshButton_Click" />
private void LanguageChangedRefreshButton_Click(object sender, RoutedEventArgs e)
{
Languages.ReloadFiles();
Loc.Instance.RaiseLanguageChangeEvents();
}
public static void ReloadFiles()
{
string exampleFileFileName = Path.Combine(languagesFilesDirectory, "Example1.loc.json");
LocalizationLoader.Instance.ClearAllTranslations();
LocalizationLoader.Instance.AddFile(exampleFileFileName);
}
Many thanks @codingseb.
Hi @codingseb , I am coding to help user can change language in real-time. That mean user change in .tm.json file and save in text editor, in UI when user refresh button it change language automatically How can I reach it?