用于RTL语言的aspnetboilerplate Angular Cli switch css

时间:2017-09-13 14:06:27

标签: angular-cli asp.net-core-1.1 aspnetboilerplate

我正在开发一个aspnetboilerplate Angular 4项目,我想替换RTL语言的css文件。

如果由于Angular Cli生成的静态页面无法实现,请告诉我如何为RTL语言选择不同的index.html文件(比如index-ar.html),具体取决于当前的语言。以下代码:

        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();
            }
        });

在上面的代码中,它总是选择index.html,所以我想检查当前的语言,并希望设置“index-rtl.html”的路径。

1 个答案:

答案 0 :(得分:0)

我能够使用以下代码解决问题:

            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"到我的家庭组件,这个解决方案工作得很好。

相关问题