简体   繁体   English

在春季启动时集成Angular 5 i18n模块和国际化

[英]Integration Angular 5 i18n module and internationalization in spring boot

i'm trying to integrate Angular i18n module in our spring boot application and i have some problems with base href. 我正在尝试将Angular i18n模块集成到我们的Spring Boot应用程序中,而我却遇到了一些基本href问题。 I've build our application for each language 'de' and 'en' like https://medium.com/@feloy/deploying-an-i18n-angular-app-with-angular-cli-fc788f17e358 and then copied my resources to backend. 我已经为https://medium.com/@feloy/deploying-an-i18n-angular-app-with-angular-cli-fc788f17e358之类的每种语言'de'和'en'构建了我们的应用程序,然后复制了我的资源到后端。

Hier is my build script in package.json for prod: Hier是我在package.json中用于生产的构建脚本:

"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"

} }

For Spring configuration i did this: 对于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);
}
}

When i try to give this url in my browser .../myapp/de then i will get /de/myapp/de which is the base href part 'de' or 'en'. 当我尝试在浏览器中提供此URL ... / myapp / de时,我将获得/ de / myapp / de,这是基本href部分“ de”或“ en”。

How can i remove the base href from url? 如何从网址中删除基本href? what am i doing wrong hier? 嗨,我在做什么错?

Thanks for your help Eli 谢谢您的帮助Eli

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM