aspnetboilerplate Angular RTL 语言的 Cli 开关 css
aspnetboilerplate Angular Cli switch css for RTL languages
我正在开发 aspnetboilerplate Angular 4 项目,我想为 RTL 语言替换 css 文件。
如果由于 Angular Cli 生成的静态页面而无法实现,请告诉我如何 select 一个不同的 index.html 文件(比如说索引-ar.html) 对于 RTL 语言,取决于以下代码中的当前语言:
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 404
&& !Path.HasExtension(context.Request.Path.Value))
{
context.Request.Path = "/index.html";
await next();
}
});
在上面的代码中,它总是selecting index.html,所以我想检查当前语言并想设置"index-rtl.html"的路径。
我能够使用以下代码解决问题:
if (context.Response.StatusCode == 404
&& !Path.HasExtension(context.Request.Path.Value))
{
string culture = "en";
if (context.Request.Cookies.ContainsKey("Abp.Localization.CultureName"))
{
culture = context.Request.Cookies["Abp.Localization.CultureName"];
}
if (context.Request.Path.Value == "app/ar" || culture=="ar")
context.Request.Path = "/ar/index.html";
else
context.Request.Path = "/index.html";
await next();
}
我有两个索引文件,对于英语,我在 wwwwroot 文件夹中有文件,而对于阿拉伯语 index.html 文件,在 wwwwroot\ar 文件夹中。在 Angular 级别,我将 "app/ar" 的路径设置为我的主组件,此解决方案运行良好。
我正在开发 aspnetboilerplate Angular 4 项目,我想为 RTL 语言替换 css 文件。
如果由于 Angular Cli 生成的静态页面而无法实现,请告诉我如何 select 一个不同的 index.html 文件(比如说索引-ar.html) 对于 RTL 语言,取决于以下代码中的当前语言:
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 404
&& !Path.HasExtension(context.Request.Path.Value))
{
context.Request.Path = "/index.html";
await next();
}
});
在上面的代码中,它总是selecting index.html,所以我想检查当前语言并想设置"index-rtl.html"的路径。
我能够使用以下代码解决问题:
if (context.Response.StatusCode == 404
&& !Path.HasExtension(context.Request.Path.Value))
{
string culture = "en";
if (context.Request.Cookies.ContainsKey("Abp.Localization.CultureName"))
{
culture = context.Request.Cookies["Abp.Localization.CultureName"];
}
if (context.Request.Path.Value == "app/ar" || culture=="ar")
context.Request.Path = "/ar/index.html";
else
context.Request.Path = "/index.html";
await next();
}
我有两个索引文件,对于英语,我在 wwwwroot 文件夹中有文件,而对于阿拉伯语 index.html 文件,在 wwwwroot\ar 文件夹中。在 Angular 级别,我将 "app/ar" 的路径设置为我的主组件,此解决方案运行良好。