Skip to content

Instantly share code, notes, and snippets.

@dansiegel
Created May 30, 2020 20:16
Show Gist options
  • Save dansiegel/ba053c8819e4755177b4175a9af16134 to your computer and use it in GitHub Desktop.
Save dansiegel/ba053c8819e4755177b4175a9af16134 to your computer and use it in GitHub Desktop.
ILocalize Sample
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>();
}
}
public class ModuleA : IModule
{
private ILocalize _localize { get; }
public ModuleA(ILocalize localize)
{
_localize = localize;
}
public void OnInitialized(IContainerProvider containerProvider)
{
localize.RegisterManager(ModuleAResources.ResourceManager);
}
}
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