Created
May 30, 2020 20:16
-
-
Save dansiegel/ba053c8819e4755177b4175a9af16134 to your computer and use it in GitHub Desktop.
ILocalize Sample
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
public partial class App : PrismApplication | |
{ | |
protected override void OnInitialized() | |
{ | |
var localize = Container.Resolve<ILocalize>(); | |
localize.RegisterManager(CoreAppResources.ResourceManager); | |
// If you don't want to use the current UI Culture | |
localize.SetCulture(new CultureInfo("es"); | |
} | |
protected override void RegisterTypes(IContainerRegistry containerRegistry) | |
{ | |
containerRegistry.RegisterSingleton<ILocalize, ResxLocalize>(); | |
} | |
protected override void ConfigureModules(IModuleCatalog moduleCatalog) | |
{ | |
moduleCatalog.AddModule<ModuleA>(); | |
moduleCatalog.AddModule<ModuleB>(); | |
} | |
} |
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
public class ModuleA : IModule | |
{ | |
private ILocalize _localize { get; } | |
public ModuleA(ILocalize localize) | |
{ | |
_localize = localize; | |
} | |
public void OnInitialized(IContainerProvider containerProvider) | |
{ | |
localize.RegisterManager(ModuleAResources.ResourceManager); | |
} | |
} |
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
public class SomeViewModel | |
{ | |
public SomeViewModel(ILocalize localize) | |
{ | |
LocalizedString = localize["SomeKey"]; | |
} | |
public string LocalizedString { get; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment