LoginSignup
6
3

More than 3 years have passed since last update.

material-tableの日本語Localization

Posted at

material-tableのローカライズ方法は、ここに記載されています。
日本語について定義を作ってみたのでメモ。

確認環境

typescript: 4.0.3
material-table: 1.69.1
@material-ui/core: 4.11.0

定義

import { Localization } from "material-table";

const localizationJapanese: Localization = {
  error: "エラー",
  body: {
    emptyDataSourceMessage: "表示するレコードがありません。",
    filterRow: {
      filterPlaceHolder: "",
      filterTooltip: "フィルター",
    },
    editRow: {
      saveTooltip: "保存",
      cancelTooltip: "キャンセル",
      deleteText: "この行を削除しますか?",
    },
    addTooltip: "追加",
    deleteTooltip: "削除",
    editTooltip: "編集",
  },
  header: {
    actions: "アクション",
  },
  grouping: {
    groupedBy: "グループ化:",
    placeholder: "ヘッダーをドラッグ ...",
  },
  pagination: {
    firstTooltip: "最初のページ",
    firstAriaLabel: "最初のページ",
    previousTooltip: "前のページ",
    previousAriaLabel: "前のページ",
    nextTooltip: "次のページ",
    nextAriaLabel: "次のページ",
    labelDisplayedRows: "{from}-{to} 全{count}件",
    labelRowsPerPage: "ページあたりの行数:",
    lastTooltip: "最後のページ",
    lastAriaLabel: "最後のページ",
    labelRowsSelect: "",
  },
  toolbar: {
    addRemoveColumns: "列の追加、削除",
    nRowsSelected: "{0} 行選択",
    showColumnsTitle: "列の表示",
    showColumnsAriaLabel: "列の表示",
    exportTitle: "出力",
    exportAriaLabel: "出力",
    exportCSVName: "CSV出力",
    exportPDFName: "PDF出力",
    searchTooltip: "検索",
    searchPlaceholder: "検索",
    searchAriaLabel: "検索",
    clearSearchAriaLabel: "クリア",
  },
};

使用イメージ

const MyTable = () => {
  return (
    <div style={{ maxWidth: "100%" }}>
      <MaterialTable
        title="Custom Edit Component Preview"
        columns={[
          {
            title: "Name",
            field: "name",
          },
          { title: "Surname", field: "surname" },
          { title: "Birth Year", field: "birthYear", type: "numeric" },
          {
            title: "Birth Place",
            field: "birthCity",
            lookup: { 34: "İstanbul", 63: "Şanlıurfa" },
          },
        ]}
        data={[
          { name: "Mehmet", surname: "Baran", birthYear: 1987, birthCity: 63 },
          {
            name: "Zerya Betül",
            surname: "Baran",
            birthYear: 2017,
            birthCity: 34,
          },
        ]}
        localization={localizationJapanese}
      />
    </div>
  );
};
6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3