-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,010 additions
and
39 deletions.
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
34 changes: 34 additions & 0 deletions
34
src/Infrastructure/Constants/Localization/LocalizationConstants.cs
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,34 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CleanArchitecture.Razor.Infrastructure.Constants.Localization | ||
{ | ||
public static class LocalizationConstants | ||
{ | ||
public static readonly LanguageCode[] SupportedLanguages = { | ||
new LanguageCode | ||
{ | ||
Code = "en-US", | ||
DisplayName= "English" | ||
}, | ||
|
||
new LanguageCode | ||
{ | ||
Code = "zh-CN", | ||
DisplayName = "中文" | ||
} | ||
}; | ||
} | ||
|
||
public class LanguageCode | ||
{ | ||
public string DisplayName { get; set; } | ||
public string Code { get; set; } | ||
} | ||
} |
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
60 changes: 60 additions & 0 deletions
60
src/SmartAdmin.WebUI/Extensions/RequestLocalizationCookiesMiddlewareExtensions.cs
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,60 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Localization; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace SmartAdmin.WebUI.Extensions | ||
{ | ||
public static class RequestLocalizationCookiesMiddlewareExtensions | ||
{ | ||
public static IApplicationBuilder UseRequestLocalizationCookies(this IApplicationBuilder app) | ||
{ | ||
app.UseMiddleware<RequestLocalizationCookiesMiddleware>(); | ||
return app; | ||
} | ||
} | ||
|
||
public class RequestLocalizationCookiesMiddleware : IMiddleware | ||
{ | ||
public CookieRequestCultureProvider Provider { get; } | ||
|
||
public RequestLocalizationCookiesMiddleware(IOptions<RequestLocalizationOptions> requestLocalizationOptions) | ||
{ | ||
Provider = | ||
requestLocalizationOptions | ||
.Value | ||
.RequestCultureProviders | ||
.Where(x => x is CookieRequestCultureProvider) | ||
.Cast<CookieRequestCultureProvider>() | ||
.FirstOrDefault(); | ||
} | ||
|
||
public async Task InvokeAsync(HttpContext context, RequestDelegate next) | ||
{ | ||
if (Provider != null) | ||
{ | ||
var feature = context.Features.Get<IRequestCultureFeature>(); | ||
|
||
if (feature != null) | ||
{ | ||
// remember culture across request | ||
context.Response | ||
.Cookies | ||
.Append( | ||
Provider.CookieName, | ||
CookieRequestCultureProvider.MakeCookieValue(feature.RequestCulture) | ||
); | ||
} | ||
} | ||
|
||
await next(context); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/SmartAdmin.WebUI/Pages/Shared/Components/LanguageSelector/Default.cshtml
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,11 @@ | ||
@model SmartAdmin.WebUI.Pages.Shared.Components.LanguageSelector.DefaultModel | ||
<div class="dropdown-menu"> | ||
@foreach (var culture in Model.SupportedCultures) | ||
{ | ||
<form method="GET"> | ||
<input type="hidden" name="culture" value="@culture.Name" /> | ||
<a href="javascript:void()" onclick="this.parentElement.submit();" class="dropdown-item" >@culture.DisplayName</a> | ||
</form> | ||
} | ||
</div> | ||
|
19 changes: 19 additions & 0 deletions
19
src/SmartAdmin.WebUI/Pages/Shared/Components/LanguageSelector/Default.cshtml.cs
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,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using CleanArchitecture.Razor.Infrastructure.Constants.Localization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace SmartAdmin.WebUI.Pages.Shared.Components.LanguageSelector | ||
{ | ||
|
||
public class DefaultModel | ||
{ | ||
public CultureInfo CurrentUICulture { get; set; } | ||
public List<CultureInfo> SupportedCultures { get; set; } | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,45 +1,40 @@ | ||
<div class="dropdown-header bg-trans-gradient d-flex flex-row py-4 rounded-top"> | ||
<div class="d-flex flex-row align-items-center mt-1 mb-1 color-white"> | ||
<span class="mr-2"> | ||
<img src="@(User.GetProfilePictureDataUrl())" class="rounded-circle profile-image" alt="@(User.GetDisplayName())"> | ||
</span> | ||
<div class="info-card-text"> | ||
<div class="fs-lg text-truncate text-truncate-lg">@(User.GetDisplayName())</div> | ||
<span class="text-truncate text-truncate-md opacity-80">@(User.GetEmail())</span> | ||
</div> | ||
</div> | ||
@inject Microsoft.AspNetCore.Mvc.Localization.IViewLocalizer _localizer | ||
<div class="dropdown-header bg-trans-gradient d-flex flex-row py-4 rounded-top"> | ||
<div class="d-flex flex-row align-items-center mt-1 mb-1 color-white"> | ||
<span class="mr-2"> | ||
<img src="@(User.GetProfilePictureDataUrl())" class="rounded-circle profile-image" alt="@(User.GetDisplayName())"> | ||
</span> | ||
<div class="info-card-text"> | ||
<div class="fs-lg text-truncate text-truncate-lg">@(User.GetDisplayName())</div> | ||
<span class="text-truncate text-truncate-md opacity-80">@(User.GetEmail())</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="dropdown-divider m-0"></div> | ||
<a href="#" class="dropdown-item" data-action="app-reset"> | ||
<span data-i18n="drpdwn.reset_layout">Reset Layout</span> | ||
<span data-i18n="drpdwn.reset_layout">@_localizer["Reset Layout"]</span> | ||
</a> | ||
<a href="#" class="dropdown-item" data-toggle="modal" data-target=".js-modal-settings"> | ||
<span data-i18n="drpdwn.settings">Settings</span> | ||
<span data-i18n="drpdwn.settings">@_localizer["Settings"]</span> | ||
</a> | ||
<div class="dropdown-divider m-0"></div> | ||
<a href="#" class="dropdown-item" data-action="app-fullscreen"> | ||
<span data-i18n="drpdwn.fullscreen">Fullscreen</span> | ||
<i class="float-right text-muted fw-n">F11</i> | ||
<span data-i18n="drpdwn.fullscreen">@_localizer["Fullscreen"]</span> | ||
<i class="float-right text-muted fw-n">F11</i> | ||
</a> | ||
<a href="#" class="dropdown-item" data-action="app-print"> | ||
<span data-i18n="drpdwn.print">Print</span> | ||
<i class="float-right text-muted fw-n">Ctrl + P</i> | ||
<span data-i18n="drpdwn.print">@_localizer["Print"]</span> | ||
<i class="float-right text-muted fw-n">Ctrl + P</i> | ||
</a> | ||
<div class="dropdown-multilevel dropdown-multilevel-left"> | ||
<div class="dropdown-item"> | ||
Language | ||
</div> | ||
<div class="dropdown-menu"> | ||
<a href="#?lang=fr" class="dropdown-item" data-action="lang" data-lang="fr">Français</a> | ||
<a href="#?lang=en" class="dropdown-item active" data-action="lang" data-lang="en">English (US)</a> | ||
<a href="#?lang=es" class="dropdown-item" data-action="lang" data-lang="es">Español</a> | ||
<a href="#?lang=ru" class="dropdown-item" data-action="lang" data-lang="ru">Русский язык</a> | ||
<a href="#?lang=jp" class="dropdown-item" data-action="lang" data-lang="jp">日本語</a> | ||
<a href="#?lang=ch" class="dropdown-item" data-action="lang" data-lang="ch">中文</a> | ||
</div> | ||
<div class="dropdown-item"> | ||
@_localizer["Language"] | ||
</div> | ||
<vc:language-selector /> | ||
|
||
</div> | ||
<div class="dropdown-divider m-0"></div> | ||
<a class="dropdown-item fw-500 pt-3 pb-3" asp-area="Identity" asp-page="/account/logout"> | ||
<span data-i18n="drpdwn.page-logout">Logout</span> | ||
<span class="float-right fw-n">@(User.Identity.Name)</span> | ||
<span data-i18n="drpdwn.page-logout">@_localizer["Logout"]</span> | ||
<span class="float-right fw-n">@(User.Identity.Name)</span> | ||
</a> |
129 changes: 129 additions & 0 deletions
129
src/SmartAdmin.WebUI/Resources/Areas/Identity/Pages/_PageHeader.en.resx
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,129 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<root> | ||
<!-- | ||
Microsoft ResX Schema | ||
Version 2.0 | ||
The primary goals of this format is to allow a simple XML format | ||
that is mostly human readable. The generation and parsing of the | ||
various data types are done through the TypeConverter classes | ||
associated with the data types. | ||
Example: | ||
... ado.net/XML headers & schema ... | ||
<resheader name="resmimetype">text/microsoft-resx</resheader> | ||
<resheader name="version">2.0</resheader> | ||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | ||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | ||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | ||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | ||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | ||
<value>[base64 mime encoded serialized .NET Framework object]</value> | ||
</data> | ||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | ||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | ||
<comment>This is a comment</comment> | ||
</data> | ||
There are any number of "resheader" rows that contain simple | ||
name/value pairs. | ||
Each data row contains a name, and value. The row also contains a | ||
type or mimetype. Type corresponds to a .NET class that support | ||
text/value conversion through the TypeConverter architecture. | ||
Classes that don't support this are serialized and stored with the | ||
mimetype set. | ||
The mimetype is used for serialized objects, and tells the | ||
ResXResourceReader how to depersist the object. This is currently not | ||
extensible. For a given mimetype the value must be set accordingly: | ||
Note - application/x-microsoft.net.object.binary.base64 is the format | ||
that the ResXResourceWriter will generate, however the reader can | ||
read any of the formats listed below. | ||
mimetype: application/x-microsoft.net.object.binary.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.soap.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.bytearray.base64 | ||
value : The object must be serialized into a byte array | ||
: using a System.ComponentModel.TypeConverter | ||
: and then encoded with base64 encoding. | ||
--> | ||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | ||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | ||
<xsd:element name="root" msdata:IsDataSet="true"> | ||
<xsd:complexType> | ||
<xsd:choice maxOccurs="unbounded"> | ||
<xsd:element name="metadata"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" use="required" type="xsd:string" /> | ||
<xsd:attribute name="type" type="xsd:string" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="assembly"> | ||
<xsd:complexType> | ||
<xsd:attribute name="alias" type="xsd:string" /> | ||
<xsd:attribute name="name" type="xsd:string" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="data"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | ||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="resheader"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:choice> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:schema> | ||
<resheader name="resmimetype"> | ||
<value>text/microsoft-resx</value> | ||
</resheader> | ||
<resheader name="version"> | ||
<value>2.0</value> | ||
</resheader> | ||
<resheader name="reader"> | ||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<resheader name="writer"> | ||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<data name="Already a member?" xml:space="preserve"> | ||
<value>Already a member?</value> | ||
</data> | ||
<data name="Secure Login" xml:space="preserve"> | ||
<value>Secure Login</value> | ||
</data> | ||
<data name="Register account" xml:space="preserve"> | ||
<value>Register account</value> | ||
</data> | ||
</root> |
Oops, something went wrong.