我创建了一个全新的jhipster项目。在其中,我还创建了一些实体组件,希望将其作为嵌套组件重用。当我创建一个新模块并在一个新组件中尝试将实体用作嵌套组件时,翻译不起作用:
我正在新模块/组件中使用实体组件,如下所示(jhi-pet是实体组件的选择器):
<mat-card>
<h1>Main Content....</h1>
<jhi-pet></jhi-pet>
如图所示,实体列表显示在新组件中,但翻译不起作用。
另一个选择是作为路径链接到实体(如下)
{
path: 'pet', component: PetComponent
}
同一问题。实体列表被显示,但没有翻译。
如果我像/ pets这样直接进入实体页面,则翻译有效...
这是我的jhipster配置:
"generator-jhipster": {
"promptValues": {
"packageName": "com.rem.app",
"nativeLanguage": "tr"
},
"jhipsterVersion": "5.2.1",
"applicationType": "monolith",
"baseName": "REM",
"packageName": "com.rem.app",
"packageFolder": "com/rem/app",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "ehcache",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "postgresql",
"searchEngine": "elasticsearch",
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSwaggerCodegen": false,
"jwtSecretKey": "replaced-by-jhipster-info",
"clientFramework": "angularX",
"useSass": true,
"clientPackageManager": "yarn",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "tr",
"languages": [
"tr",
"en",
"de"
您知道我如何使用适当的翻译吗?
谢谢您的帮助。
答案 0 :(得分:1)
找到答案了!
在使用实体作为嵌套组件的新模块中,将其添加到构造函数中
constructor(private languageService: JhiLanguageService, private languageHelper: JhiLanguageHelper) {
this.languageHelper.language.subscribe((languageKey: string) => {
if (languageKey !== undefined) {
this.languageService.changeLanguage(languageKey);
}
});
}