javascript - ReactJS:使用 react-jhipster 进行翻译
问题描述
我正在尝试使用 react-jhipster 来使用翻译
我创建了一个 js 文件:
翻译.js
export const english =
{
"my_key": "delete"
}
在我要获得翻译的页面中:
import { Translate, TextFormat, getSortState, IPaginationBaseState, JhiPagination, JhiItemCount, translate } from 'react-jhipster';
import { english } from '../../../../i18n/eng/translation';
// In my render I'm going to use like this:
<span className="d-none d-md-inline">
<Translate contentKey={english.my_key} />
</span>
但它什么也没显示
翻译是:
import * as React from 'react';
export interface ITranslateProps {
contentKey: string;
children?: string | JSX.Element | Array<string | JSX.Element>;
interpolate?: any;
component?: string;
}
/**
* Translates the given key using provided i18n values
*/
declare class Translate extends React.Component<ITranslateProps> {
static defaultProps: {
component: string;
};
shouldComponentUpdate(): boolean;
render(): React.DOMElement<{
dangerouslySetInnerHTML: {
__html: any;
};
}, Element>;
}
export declare const translate: (contentKey: string, interpolate?: any, children?: string) => any;
export default Translate;
我该如何使用它?
谢谢
解决方案
推荐阅读
- powershell - 从数组的重复记录中选择字段
- azure-language-understanding - 为什么 LUIS 中缺少“机器学习”实体和“描述符”?
- bash - 让 CloudFormation 等待用户数据
- r - dplyr - 如何将二进制和互斥列折叠为 1?
- c# - 将数组与 ListView 合并
- c - 如何让 malloc 每次使用 MSVC 返回相同的地址?
- django - Django 页面错误 404 - 通过 uri 加载 JSON
- c# - 我什么时候应该使用 StringComparison.InvariantCulture 而不是 StringComparison.CurrentCulture 来测试字符串是否相等?
- geopandas - 如何将凸包顶点转换为 geopandas 多边形
- splunk - 如何 Splunk 搜索中位延迟超过 3 秒的交易类型