集成 Angular 5 i18n 模块和 Spring 启动中的国际化



我正在尝试将 Angular i18n 模块集成到我们的 Spring 启动应用程序中,但我对基本 href 有一些问题。我已经为每种语言"de"和"en"构建了我们的应用程序,就像 https://medium.com/@feloy/deploying-an-i18n-angular-app-with-angular-cli-fc788f17e358 一样,然后将我的资源复制到后端。

Hier 是我在 package.json 中用于 prod 的构建脚本:

"scripts": {
"ng": "ng",
"start-local": "ng serve --env=local",
"build": "ng build",
"buildProd": "for lang in de en; do ng build --output-path=dist/$lang -prod --bh /$lang/ --i18n-file=src/i18n/messages.$lang.xlf --i18n-format=xlf --locale=$lang; done",
"test": "ng test",
"test-coverage": "ng test --code-coverage",
"lint": "ng lint",
"e2e": "ng e2e",
"i18n": "ng xi18n --output-path src/i18n"

}

对于 Spring 配置,我这样做了:

@EnableEurekaClient
@SpringBootApplication
public class ProviderApplication extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/myapp/de/**").setViewName("/de/index.html");
    registry.addViewController("/myapp/en/**").setViewName("/en/index.html");
}
public static void main(String[] args) {
    SpringApplication.run(UiProviderApplication.class, args);
}
}

当我尝试在我的浏览器中提供这个网址时....../myapp/de,那么我会得到/de/myapp/de,这是基本的href部分'de'或'en'。

如何从 url 中删除基本 href? 我做错了什么?

感谢您的帮助伊

--deploy-url=/$lang/而不是 base-href 解决了我的问题

最新更新