forked from chocolatey/ChocolateyGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chocolateyGH-533) Added ability to notify when language is changed
- Loading branch information
1 parent
274a277
commit d044fd0
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright company="Chocolatey" file="TranslationSource.cs"> | ||
// Copyright 2014 - Present Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
using System.Globalization; | ||
using System.Resources; | ||
using ChocolateyGui.Base; | ||
using ChocolateyGui.Properties; | ||
|
||
namespace ChocolateyGui.Utilities | ||
{ | ||
public sealed class TranslationSource : ObservableBase | ||
{ | ||
private readonly ResourceManager resourceManager = Resources.ResourceManager; | ||
private CultureInfo currentCulture = null; | ||
|
||
public static TranslationSource Instance { get; } = new TranslationSource(); | ||
|
||
public CultureInfo CurrentCulture | ||
{ | ||
get | ||
{ | ||
return currentCulture; | ||
} | ||
|
||
set | ||
{ | ||
if (currentCulture != value) | ||
{ | ||
currentCulture = value; | ||
NotifyPropertyChanged(string.Empty); // We call with an empty string on purpose to force an update for all resource strings. | ||
} | ||
} | ||
} | ||
|
||
public string this[string key] => resourceManager.GetString(key, CurrentCulture); | ||
} | ||
} |