translation-not-found使用generator jhipster在html模板中显示国际化数据

时间:2017-11-18 11:25:09

标签: angular internationalization jhipster

我正在使用generator-jhipster来开发应用程序。但是i18n不会显示

错误:translation-not-found [error.title]

enter image description here

打击是我的代码:

.yo-rc.json

{
    "generator-jhipster": {
        "promptValues": {
            "packageName": "com.myApp.app"
        },
        "jhipsterVersion": "4.5.1",
        "baseName": "myapp",
        "packageName": "com.myapp.app",
        "packageFolder": "com/myapp/app",
        .......,
        "clientFramework": "angularX",
        "useSass": true,
        "clientPackageManager": "yarn",
        "applicationType": "gateway",
        "testFrameworks": [],
        "jhiPrefix": "jhi",
        "enableTranslation": true,
        "skipServer": true,
        "languages": [
            "en"
        ]
    }
}

error.component.html

<div class="row">
    <div class="col-md-12">
        <h1 jhiTranslate="error.title">Error Page!</h1>

        <div [hidden]="!errorMessage">
            <div class="alert alert-danger">{{errorMessage}}
            </div>
        </div>
        <div [hidden]="!error403" class="alert alert-danger" jhiTranslate="error.403">You are not authorized to access the page.
        </div>
    </div>
</div>

error.json文件包含以下位置:src =&gt; main =&gt; webapp =&gt; i18n =&gt; en =&gt; error.json

error.json

{
    "error": {
        "title": "Error page!",
        "403": "You are not authorized to access the page."
    }
}

0 个答案:

没有答案