简体   繁体   中英

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

Hier is my build script in package.json for 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"

}

For Spring configuration i did this:

@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'.

How can i remove the base href from url? what am i doing wrong hier?

Thanks for your help Eli

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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