GitHub user dosubot[bot] added a comment to the discussion: superset
localisation
<!-- Answer -->
To add language localization to a chart and its response in Superset, you can
use the `i18n.ts` file to define translations for different languages. Here's
an example of how you can add translations for English, French, and Chinese:
```typescript
import { Locale } from '@superset-ui/core';
const en = {
'Query Mode': [''],
Aggregate: [''],
'Raw Records': [''],
'Emit Filter Events': [''],
'Show Cell Bars': [''],
'page_size.show': ['Show'],
'page_size.all': ['All'],
'page_size.entries': ['entries'],
'table.previous_page': ['Previous'],
'table.next_page': ['Next'],
'search.num_records': ['%s record', '%s records...'],
};
const translations: Partial<Record<Locale, typeof en>> = {
en,
fr: {
'Query Mode': [''],
Aggregate: [''],
'Raw Records': [''],
'Emit Filter Events': [''],
'Show Cell Bars': [''],
'page_size.show': ['Afficher'],
'page_size.all': ['tous'],
'page_size.entries': ['entrées'],
'table.previous_page': ['Précédent'],
'table.next_page': ['Suivante'],
'search.num_records': ['%s enregistrement', '%s enregistrements...'],
},
zh: {
'Query Mode': ['查询模式'],
Aggregate: ['分组聚合'],
'Raw Records': ['原始数据'],
'Emit Filter Events': ['关联看板过滤器'],
'Show Cell Bars': ['为指标添加条状图背景'],
'page_size.show': ['每页显示'],
'page_size.all': ['全部'],
'page_size.entries': ['条'],
'table.previous_page': ['上一页'],
'table.next_page': ['下一页'],
'search.num_records': ['%s条记录...'],
'second': ['秒'],
'Copy of %s': ['%s 的副本'],
},
ja: {
'Check out this chart: ': ['このチャートをチェックしてください:'],
'Check out this dashboard: ': ['このダッシュボードを確認してください: '],
'Check to force date partitions to have the same height':
['日付パーティションを強制的に同じ高さにする場合にオンにします。'],
'Child label position': ['子ラベルの位置'],
'Choice of [Label] must be present in [Group By]':
['[グループ化]に[ラベル]の選択肢が存在する必要があります。'],
'Choice of [Point Radius] must be present in [Group By]':
['[グループ化]に[点半径]の選択肢が存在する必要があります。'],
'Choose File': ['ファイルを選択'],
'Choose a chart or dashboard not both': ['両方ではなくチャートまたはダッシュボードを選択してください。'],
'Choose a database...': ['データベースを選択してください...'],
'Choose a dataset': ['データセットを選択'],
'Choose a metric for right axis': ['右軸の指標を選択'],
'Choose a number format': ['数値形式を選択してください'],
'Choose a source': ['ソースを選択してください'],
'Choose a source and a target': ['ソースとターゲットを選択してください'],
'Choose a target': ['ターゲットを選択してください'],
'Choose chart type': ['グラフの種類を選択してください'],
'Choose the annotation layer type': ['注釈レイヤーのタイプを選んでください'],
'Choose the format for legend values': ['凡例値の形式を選択します'],
'Choose the position of the legend': ['凡例の位置を選択してください'],
'Choose the source of your annotations': ['注釈のソースを選択する'],
},
};
export default translations;
```
This code snippet shows how to define translations for different UI elements
and messages in multiple languages. You can extend this by adding more
languages or additional translation keys as needed
<sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-table/src/i18n.ts)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
---
<sup>Help Dosu learn! Give it feedback: [Great
Response](https://app.dosu.dev/response-feedback/72e78415-7238-46f8-9015-bac97d5e03af?feedback_type=great_response)
| [Irrelevant
Answer](https://app.dosu.dev/response-feedback/72e78415-7238-46f8-9015-bac97d5e03af?feedback_type=irrelevant_answer)
| [Incorrect
Sources](https://app.dosu.dev/response-feedback/72e78415-7238-46f8-9015-bac97d5e03af?feedback_type=incorrect_sources)
| [Too
Verbose](https://app.dosu.dev/response-feedback/72e78415-7238-46f8-9015-bac97d5e03af?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/72e78415-7238-46f8-9015-bac97d5e03af?feedback_type=hallucination)
| [Bug
Report](https://app.dosu.dev/response-feedback/72e78415-7238-46f8-9015-bac97d5e03af?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/72e78415-7238-46f8-9015-bac97d5e03af?feedback_type=other)</sup>
GitHub link:
https://github.com/apache/superset/discussions/33005#discussioncomment-12732555
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]