我正在尝试在.NET核心2.1中创建一个角度多语言应用程序。
用别人的成语服务。我使用app.map在startup.cs中运行不同的npmscripts。
app.Map("/fr-FR", spaFr =>
{
spaFr.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
spa.Options.DefaultPage = $"/fr-FR/index.html";
if (env.IsDevelopment())
{
spa.UseAngularCliServer(npmScript: "start:fr");
}
});
});
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
spa.Options.DefaultPage = $"/index.html";
if (env.IsDevelopment())
{
spa.UseAngularCliServer(npmScript: "start");
}
});
所以
http://localhost:52337
用英语服务应用程序
http://localhost:52337/fr-FR
在法国提供应用程序
但是当我写的时候
http://localhost:52337/fr-fr
应用程序找不到bundles文件:styles.a06ff9ecb31fc360851.css、runtime.a66f828dca56eeb90e02.js、polyfills.662173b507c7bb60d452.js和main.ddceca57cc95aeab5c91.js
而且.NET找不到这些文件,因为它正在查找
http://localhost:52337/
,但文件在
http://localhost:52337/fr-fr
我的package.json有脚本
"start": "ng serve",
"start:fr": "ng serve --serve-path=/ --base-href=/fr-FR --configuration=fr",
我在配置中添加了angular.json
"production-fr": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"outputPath": "dist/fr-FR/",
"i18nFile": "src/i18n/messages.fr.xlf",
"i18nFormat": "xlf",
"i18nLocale": "fr",
"i18nMissingTranslation": "error"
},
"fr": {
"aot": true,
"outputHashing": "all",
"serve-path":"/fr-FR/",
"i18nFile": "src/i18n/messages.fr.xlf",
"i18nFormat": "xlf",
"i18nLocale": "fr",
"i18nMissingTranslation": "error"
}
我认为我在脚本中进行了所有可能的组合,使用或不使用--serve-path,--deploy-url,--base-href…但我可以在开发环境中实现这一点。会发生什么?