Skip to content

Commit

Permalink
Updated Example1 to use new localization code
Browse files Browse the repository at this point in the history
  • Loading branch information
JonPSmith committed Dec 26, 2022
1 parent 5f3fa6d commit 37bac78
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 500 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

namespace Example1.RazorPages.IndividualAccounts;

public class Example1Resources
/// <summary>
/// This defines the localize resource file groups for the localization within this ASP.NET Core app
/// </summary>
public class AppResourceClass
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Example1.RazorPages.IndividualAccounts;

/// <summary>
/// This defines the localize resource file groups for the localization within the AuthPermissions.AspNetCore code
/// </summary>
public class AuthPLocalizeResource
{

Expand Down
8 changes: 2 additions & 6 deletions Example1.RazorPages.IndividualAccounts/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ public class IndexModel : PageModel
private readonly UserManager<IdentityUser> _userManager;
private readonly IStringLocalizer _localizer;

public IndexModel(UserManager<IdentityUser> userManager, IStringLocalizerFactory factory)
public IndexModel(UserManager<IdentityUser> userManager, IStringLocalizer<AppResourceClass> localizer)
{
_userManager = userManager;
var type = typeof(ResourceLocalize);
var assemblyName = new AssemblyName(type.GetTypeInfo().Assembly.FullName);
_localizer = factory.Create("ResourceLocalize", assemblyName.Name);
_localizer = localizer;
}

[ModelBinder]
Expand All @@ -32,8 +30,6 @@ public IndexModel(UserManager<IdentityUser> userManager, IStringLocalizerFactory
public void OnGet()
{
Users = _userManager.Users.ToList();
var loc = _localizer["Test"];
var result = loc.ResourceNotFound ? "Not found: " + loc.SearchedLocation : loc.Value;
}
}
}
2 changes: 1 addition & 1 deletion Example1.RazorPages.IndividualAccounts/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static void Main(string[] args)

//Register the SimpleLocalizer with its own Resource file
//This is used for localization of simple messages
builder.Services.RegisterSimpleLocalizer<Example1Resources>();
builder.Services.RegisterSimpleLocalizer<AppResourceClass>();

builder.Services.RegisterAuthPermissions<Example1Permissions>()
.UsingInMemoryDatabase()
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 37bac78

Please sign in to comment.