gpt4 book ai didi

angular - 在 ng build --prod --localize 时更改 Angular 基 href

转载 作者:行者123 更新时间:2023-12-05 01:37:39 29 4
gpt4 key购买 nike

情况

我创建了一个具有国际化 (i18n) 的 Angular 应用程序。我想在子域中托管不同的版本,例如:

  • zh.myexample.com
  • es.myexample.com

问题

当我使用命令 ng build --prod --localize 时src/app/index.hml 中的标签 base href 添加了语言,例如:

  • <base href="/en/">
  • <base href="/es/">

我想要什么

<base href="/"> 生成每个版本

最佳答案

您可以在 angular.json 文件中为每个语言环境配置基本 href。

{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"projects": {
"my-app": {
"projectType": "application",
"...",
"i18n": {
"sourceLocale": {"code": "en-US", "baseHref": ""},
"locales": {
"de": {"translation": "", "baseHref": ""},
"de-CH": {"translation": "", "baseHref": ""},
"en-GB": {"translation": "", "baseHref": ""},
"fr-FR": {"translation": "", "baseHref": ""},
}
},

参见 https://angular.io/guide/i18n#localize-confighttps://github.com/angular/angular-cli/blob/b90c04db16b9dba85bc7689f205f4e0e4217d772/packages/angular/cli/lib/config/schema.json#L429-L432了解更多信息。

关于angular - 在 ng build --prod --localize 时更改 Angular 基 href,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60779709/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com