我修改了与国际化相关的每个文件:
src/main/resources/i18n/messages_en.properties
src/main/webapp/i18n/en/produto.json
(我的新实体)translate
span
代码添加了jhiTranslate
属性
这些更改都不适用于翻译。我已经重新运行了应用程序,在8080端口中杀死了该进程,甚至重新启动了计算机。 target
文件夹中生成的文件都使用本机语言,就好像这些文件没有更改一样,如:
在produto.component.html
:
<th jhiSortBy="nome"><span jhiTranslate="myApp.produto.nome" translate="myApp.produto.nome">Nome</span> <span class="fa fa-sort"></span></th>
在messages_en.properties
:
### ENTITIES
## PRODUCT
myApp.produto.nome=Name
myApp.produto.descricao=Description
myApp.produto.preco=Price
myApp.produto.dataVencimento=Due Date
在produto.json
:
{
"myApp": {
"produto" : {
"home": {
"title": "Products",
"createLabel": "Create a new Product",
"createOrEditLabel": "Create or edit a Product"
},
"created": "A new Product is created with identifier {{ param }}",
"updated": "A Product is updated with identifier {{ param }}",
"deleted": "A Product is deleted with identifier {{ param }}",
"delete": {
"question": "Are you sure you want to delete Product {{ id }}?"
},
"detail": {
"title": "Product"
},
"nome": "Name",
"descricao": "Description",
"preco": "Price",
"dataVencimento": "Due Date"
}
}
}
只翻译jHipster生成的默认文本。
还有解决方案吗?
答案 0 :(得分:2)
正确的文件是:src/main/webapp/i18n/en/produto.json
如果您使用./mvnw
(后端)和 yarn start
(前端)启动应用程序,则更改将自动应用于localhost:9000
否则,如果您只启动了后端,则需要使用yarn webpack:build
编译前端,然后刷新浏览器localhost:8080