언어팩을 등록하고 화면 언어 바꾸기Register a language pack and switch the grid language
작은 일본어 팩을 그리드에 주고, 한국어·영어·일본어로 바꿔 봐요. 페이저, 필터 줄, 컬럼 메뉴, 합계 줄의 문구가 따라가요.Give the grid a small Japanese pack and switch between Korean, English and Japanese. The pager, filter row, column menu and total row follow.
코드Code
탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.
이 화면은 새 모양 옵션을 켠 모양이에요: density: 'spacious', iconStyle: 'soft', motion: true (코드에 없으면 기본 모양으로 보여요)This preview has the new-look options on: density: 'spacious', iconStyle: 'soft', motion: true (without them in your code you get the default look)
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div class="toolbar">
<select aria-label="화면 언어" id="locale">
<option value="ja" selected>일본어(작은 팩)</option>
<option value="en">영어(내장)</option>
<option value="ko">한국어(내장)</option>
</select>
</div>
<div id="grid" style="height: 340px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options } from './example';
const api = createGrid(document.getElementById('grid'), options);
document.getElementById('locale').addEventListener('change', (event) => actions.locale(api, event.target.value));// 표 데이터는 어느 언어로 보아도 같게 코드와 숫자로만 만들었어요. 바뀌는 것은 그리드가 스스로 쓰는 문구예요.
const rows = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
sku: `A-${101 + i}`,
qty: 3 + ((i * 7) % 20),
price: 1200 + i * 350,
}));
const ja = {
code: 'ja',
messages: {
noRows: '表示する行がありません。',
loading: '読み込み中…',
columnMenuLabel: '列メニュー',
menuSortAsc: '昇順で並べ替え',
menuSortDesc: '降順で並べ替え',
menuHide: '列を非表示',
},
pager: {
nav: 'ページ送り',
first: '最初のページ',
previous: '前のページ',
next: '次のページ',
last: '最後のページ',
pageNumber: '{page}ページ',
pageSize: '1ページの行数',
summary: '全{total}件中 {from}–{to}件',
empty: '表示する行がありません',
},
filter: {
rowLabel: 'フィルター',
inputLabel: '{title}で絞り込み',
clearAll: 'すべてのフィルターを解除',
clearOne: '{title}のフィルターを解除',
all: 'すべて',
},
text: { summaryTotal: '合計', selectAll: 'すべて選択' },
};
// 그리드의 접근성 이름(ariaLabel)도 고른 언어로 바꿔요.
const LABELS = {
ja: 'ロケールパックのデモ',
en: 'Locale pack demo',
ko: '언어팩 데모',
};
export const options = {
ariaLabel: LABELS.ja,
columns: [
{ id: 'sku', title: 'SKU', width: 100 },
{ id: 'qty', title: 'Qty', kind: 'number', width: 90, align: 'end', aggregate: 'sum' },
{ id: 'price', title: 'Price', kind: 'number', width: 100, align: 'end', aggregate: 'sum' },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
pagination: { mode: 'client', pageSize: 5 },
filterRow: true,
columnMenu: true,
summary: true,
// 이 그리드에만 팩을 준다(전역 없음). npm 패키지에서는 registerLocale(pack)로 한 번 등록해 두면 모든 그리드가 쓴다.
locale: 'ja',
localePacks: [ja],
};
export const actions = {
// locale만 바꾸면 페이저, 필터 줄, 컬럼 메뉴, 합계 줄의 문구가 다음 화면 갱신에 새 언어로 나와요.
locale: (api, value = 'ja') => api.setOptions({ locale: value, ariaLabel: LABELS[value] ?? LABELS.en }),
};<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>언어팩을 등록하고 화면 언어 바꾸기</title>
</head>
<body>
<div class="toolbar">
<select aria-label="화면 언어" id="locale">
<option value="ja" selected>일본어(작은 팩)</option>
<option value="en">영어(내장)</option>
<option value="ko">한국어(내장)</option>
</select>
</div>
<div id="grid" style="height: 340px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// 표 데이터는 어느 언어로 보아도 같게 코드와 숫자로만 만들었어요. 바뀌는 것은 그리드가 스스로 쓰는 문구예요.
const rows = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
sku: `A-${101 + i}`,
qty: 3 + ((i * 7) % 20),
price: 1200 + i * 350,
}));
const ja = {
code: 'ja',
messages: {
noRows: '表示する行がありません。',
loading: '読み込み中…',
columnMenuLabel: '列メニュー',
menuSortAsc: '昇順で並べ替え',
menuSortDesc: '降順で並べ替え',
menuHide: '列を非表示',
},
pager: {
nav: 'ページ送り',
first: '最初のページ',
previous: '前のページ',
next: '次のページ',
last: '最後のページ',
pageNumber: '{page}ページ',
pageSize: '1ページの行数',
summary: '全{total}件中 {from}–{to}件',
empty: '表示する行がありません',
},
filter: {
rowLabel: 'フィルター',
inputLabel: '{title}で絞り込み',
clearAll: 'すべてのフィルターを解除',
clearOne: '{title}のフィルターを解除',
all: 'すべて',
},
text: { summaryTotal: '合計', selectAll: 'すべて選択' },
};
// 그리드의 접근성 이름(ariaLabel)도 고른 언어로 바꿔요.
const LABELS = {
ja: 'ロケールパックのデモ',
en: 'Locale pack demo',
ko: '언어팩 데모',
};
const options = {
ariaLabel: LABELS.ja,
columns: [
{ id: 'sku', title: 'SKU', width: 100 },
{ id: 'qty', title: 'Qty', kind: 'number', width: 90, align: 'end', aggregate: 'sum' },
{ id: 'price', title: 'Price', kind: 'number', width: 100, align: 'end', aggregate: 'sum' },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
pagination: { mode: 'client', pageSize: 5 },
filterRow: true,
columnMenu: true,
summary: true,
// 이 그리드에만 팩을 준다(전역 없음). npm 패키지에서는 registerLocale(pack)로 한 번 등록해 두면 모든 그리드가 쓴다.
locale: 'ja',
localePacks: [ja],
};
const actions = {
// locale만 바꾸면 페이저, 필터 줄, 컬럼 메뉴, 합계 줄의 문구가 다음 화면 갱신에 새 언어로 나와요.
locale: (api, value = 'ja') => api.setOptions({ locale: value, ariaLabel: LABELS[value] ?? LABELS.en }),
};
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('locale').addEventListener('change', (event) => actions.locale(api, event.target.value));
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
return (
<>
<div className="toolbar">
<select
aria-label="화면 언어"
disabled={!api}
onChange={(event) => api && actions.locale(api, event.target.value)}
>
<option value="ja">일본어(작은 팩)</option>
<option value="en">영어(내장)</option>
<option value="ko">한국어(내장)</option>
</select>
</div>
<Grid style={{ height: 340 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions, LocalePack } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
sku: string;
qty: number;
price: number;
}
// 표 데이터는 어느 언어로 보아도 같게 코드와 숫자로만 만들었어요. 바뀌는 것은 그리드가 스스로 쓰는 문구예요.
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
sku: `A-${101 + i}`,
qty: 3 + ((i * 7) % 20),
price: 1200 + i * 350,
}));
// 작은 일본어 팩이에요. 정식 팩은 번역 템플릿의 모든 키를 채우고 checkLocalePack으로 확인해요(가이드 참고).
// 여기서는 일부만 넣어서, 빠진 키가 영어로 되돌아가는 것을 보여 줘요. 예: 컬럼 메뉴의 나머지 항목, 필터 팝업.
type Partial4<T extends LocalePack> = { code: string } & {
[S in 'messages' | 'pager' | 'filter' | 'text']: Partial<T[S]>;
};
const ja: Partial4<LocalePack> = {
code: 'ja',
messages: {
noRows: '表示する行がありません。',
loading: '読み込み中…',
columnMenuLabel: '列メニュー',
menuSortAsc: '昇順で並べ替え',
menuSortDesc: '降順で並べ替え',
menuHide: '列を非表示',
},
pager: {
nav: 'ページ送り',
first: '最初のページ',
previous: '前のページ',
next: '次のページ',
last: '最後のページ',
pageNumber: '{page}ページ',
pageSize: '1ページの行数',
summary: '全{total}件中 {from}–{to}件',
empty: '表示する行がありません',
},
filter: {
rowLabel: 'フィルター',
inputLabel: '{title}で絞り込み',
clearAll: 'すべてのフィルターを解除',
clearOne: '{title}のフィルターを解除',
all: 'すべて',
},
text: { summaryTotal: '合計', selectAll: 'すべて選択' },
};
// 그리드의 접근성 이름(ariaLabel)도 고른 언어로 바꿔요.
const LABELS: Record<string, string> = {
ja: 'ロケールパックのデモ',
en: 'Locale pack demo',
ko: '언어팩 데모',
};
export const options: GridOptions<Row> = {
ariaLabel: LABELS.ja,
columns: [
{ id: 'sku', title: 'SKU', width: 100 },
{ id: 'qty', title: 'Qty', kind: 'number', width: 90, align: 'end', aggregate: 'sum' },
{ id: 'price', title: 'Price', kind: 'number', width: 100, align: 'end', aggregate: 'sum' },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
pagination: { mode: 'client', pageSize: 5 },
filterRow: true,
columnMenu: true,
summary: true,
// 이 그리드에만 팩을 준다(전역 없음). npm 패키지에서는 registerLocale(pack)로 한 번 등록해 두면 모든 그리드가 쓴다.
locale: 'ja',
localePacks: [ja as LocalePack],
};
export const actions = {
// locale만 바꾸면 페이저, 필터 줄, 컬럼 메뉴, 합계 줄의 문구가 다음 화면 갱신에 새 언어로 나와요.
locale: (api: GridApi<Row>, value = 'ja') =>
api.setOptions({ locale: value, ariaLabel: LABELS[value] ?? LABELS.en }),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
}
</script>
<template>
<div class="toolbar">
<select
aria-label="화면 언어"
:disabled="!api"
@change="api && actions.locale(api, ($event.target as HTMLSelectElement).value)"
>
<option value="ja" selected>일본어(작은 팩)</option>
<option value="en">영어(내장)</option>
<option value="ko">한국어(내장)</option>
</select>
</div>
<Grid style="height: 340px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions, LocalePack } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
sku: string;
qty: number;
price: number;
}
// 표 데이터는 어느 언어로 보아도 같게 코드와 숫자로만 만들었어요. 바뀌는 것은 그리드가 스스로 쓰는 문구예요.
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
sku: `A-${101 + i}`,
qty: 3 + ((i * 7) % 20),
price: 1200 + i * 350,
}));
// 작은 일본어 팩이에요. 정식 팩은 번역 템플릿의 모든 키를 채우고 checkLocalePack으로 확인해요(가이드 참고).
// 여기서는 일부만 넣어서, 빠진 키가 영어로 되돌아가는 것을 보여 줘요. 예: 컬럼 메뉴의 나머지 항목, 필터 팝업.
type Partial4<T extends LocalePack> = { code: string } & {
[S in 'messages' | 'pager' | 'filter' | 'text']: Partial<T[S]>;
};
const ja: Partial4<LocalePack> = {
code: 'ja',
messages: {
noRows: '表示する行がありません。',
loading: '読み込み中…',
columnMenuLabel: '列メニュー',
menuSortAsc: '昇順で並べ替え',
menuSortDesc: '降順で並べ替え',
menuHide: '列を非表示',
},
pager: {
nav: 'ページ送り',
first: '最初のページ',
previous: '前のページ',
next: '次のページ',
last: '最後のページ',
pageNumber: '{page}ページ',
pageSize: '1ページの行数',
summary: '全{total}件中 {from}–{to}件',
empty: '表示する行がありません',
},
filter: {
rowLabel: 'フィルター',
inputLabel: '{title}で絞り込み',
clearAll: 'すべてのフィルターを解除',
clearOne: '{title}のフィルターを解除',
all: 'すべて',
},
text: { summaryTotal: '合計', selectAll: 'すべて選択' },
};
// 그리드의 접근성 이름(ariaLabel)도 고른 언어로 바꿔요.
const LABELS: Record<string, string> = {
ja: 'ロケールパックのデモ',
en: 'Locale pack demo',
ko: '언어팩 데모',
};
export const options: GridOptions<Row> = {
ariaLabel: LABELS.ja,
columns: [
{ id: 'sku', title: 'SKU', width: 100 },
{ id: 'qty', title: 'Qty', kind: 'number', width: 90, align: 'end', aggregate: 'sum' },
{ id: 'price', title: 'Price', kind: 'number', width: 100, align: 'end', aggregate: 'sum' },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
pagination: { mode: 'client', pageSize: 5 },
filterRow: true,
columnMenu: true,
summary: true,
// 이 그리드에만 팩을 준다(전역 없음). npm 패키지에서는 registerLocale(pack)로 한 번 등록해 두면 모든 그리드가 쓴다.
locale: 'ja',
localePacks: [ja as LocalePack],
};
export const actions = {
// locale만 바꾸면 페이저, 필터 줄, 컬럼 메뉴, 합계 줄의 문구가 다음 화면 갱신에 새 언어로 나와요.
locale: (api: GridApi<Row>, value = 'ja') =>
api.setOptions({ locale: value, ariaLabel: LABELS[value] ?? LABELS.en }),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<select
aria-label="화면 언어"
[disabled]="!api"
(change)="api && actions.locale(api, $any($event.target).value)"
>
<option value="ja" selected>일본어(작은 팩)</option>
<option value="en">영어(내장)</option>
<option value="ko">한국어(내장)</option>
</select>
</div>
<mx-grid style="height: 340px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
}
}
}import type { GridApi, GridOptions, LocalePack } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
sku: string;
qty: number;
price: number;
}
// 표 데이터는 어느 언어로 보아도 같게 코드와 숫자로만 만들었어요. 바뀌는 것은 그리드가 스스로 쓰는 문구예요.
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
sku: `A-${101 + i}`,
qty: 3 + ((i * 7) % 20),
price: 1200 + i * 350,
}));
// 작은 일본어 팩이에요. 정식 팩은 번역 템플릿의 모든 키를 채우고 checkLocalePack으로 확인해요(가이드 참고).
// 여기서는 일부만 넣어서, 빠진 키가 영어로 되돌아가는 것을 보여 줘요. 예: 컬럼 메뉴의 나머지 항목, 필터 팝업.
type Partial4<T extends LocalePack> = { code: string } & {
[S in 'messages' | 'pager' | 'filter' | 'text']: Partial<T[S]>;
};
const ja: Partial4<LocalePack> = {
code: 'ja',
messages: {
noRows: '表示する行がありません。',
loading: '読み込み中…',
columnMenuLabel: '列メニュー',
menuSortAsc: '昇順で並べ替え',
menuSortDesc: '降順で並べ替え',
menuHide: '列を非表示',
},
pager: {
nav: 'ページ送り',
first: '最初のページ',
previous: '前のページ',
next: '次のページ',
last: '最後のページ',
pageNumber: '{page}ページ',
pageSize: '1ページの行数',
summary: '全{total}件中 {from}–{to}件',
empty: '表示する行がありません',
},
filter: {
rowLabel: 'フィルター',
inputLabel: '{title}で絞り込み',
clearAll: 'すべてのフィルターを解除',
clearOne: '{title}のフィルターを解除',
all: 'すべて',
},
text: { summaryTotal: '合計', selectAll: 'すべて選択' },
};
// 그리드의 접근성 이름(ariaLabel)도 고른 언어로 바꿔요.
const LABELS: Record<string, string> = {
ja: 'ロケールパックのデモ',
en: 'Locale pack demo',
ko: '언어팩 데모',
};
export const options: GridOptions<Row> = {
ariaLabel: LABELS.ja,
columns: [
{ id: 'sku', title: 'SKU', width: 100 },
{ id: 'qty', title: 'Qty', kind: 'number', width: 90, align: 'end', aggregate: 'sum' },
{ id: 'price', title: 'Price', kind: 'number', width: 100, align: 'end', aggregate: 'sum' },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
pagination: { mode: 'client', pageSize: 5 },
filterRow: true,
columnMenu: true,
summary: true,
// 이 그리드에만 팩을 준다(전역 없음). npm 패키지에서는 registerLocale(pack)로 한 번 등록해 두면 모든 그리드가 쓴다.
locale: 'ja',
localePacks: [ja as LocalePack],
};
export const actions = {
// locale만 바꾸면 페이저, 필터 줄, 컬럼 메뉴, 합계 줄의 문구가 다음 화면 갱신에 새 언어로 나와요.
locale: (api: GridApi<Row>, value = 'ja') =>
api.setOptions({ locale: value, ariaLabel: LABELS[value] ?? LABELS.en }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<select aria-label="Language" id="locale">
<option value="ja" selected>Japanese (small pack)</option>
<option value="en">English (built in)</option>
<option value="ko">Korean (built in)</option>
</select>
</div>
<div id="grid" style="height: 340px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options } from './example';
const api = createGrid(document.getElementById('grid'), options);
document.getElementById('locale').addEventListener('change', (event) => actions.locale(api, event.target.value));// The table data is only codes and numbers, so it looks the same in any language. What changes is the text the grid itself uses.
const rows = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
sku: `A-${101 + i}`,
qty: 3 + ((i * 7) % 20),
price: 1200 + i * 350,
}));
const ja = {
code: 'ja',
messages: {
noRows: '表示する行がありません。',
loading: '読み込み中…',
columnMenuLabel: '列メニュー',
menuSortAsc: '昇順で並べ替え',
menuSortDesc: '降順で並べ替え',
menuHide: '列を非表示',
},
pager: {
nav: 'ページ送り',
first: '最初のページ',
previous: '前のページ',
next: '次のページ',
last: '最後のページ',
pageNumber: '{page}ページ',
pageSize: '1ページの行数',
summary: '全{total}件中 {from}–{to}件',
empty: '表示する行がありません',
},
filter: {
rowLabel: 'フィルター',
inputLabel: '{title}で絞り込み',
clearAll: 'すべてのフィルターを解除',
clearOne: '{title}のフィルターを解除',
all: 'すべて',
},
text: { summaryTotal: '合計', selectAll: 'すべて選択' },
};
// The grid's accessible name (ariaLabel) also changes to the chosen language.
const LABELS = {
ja: 'ロケールパックのデモ',
en: 'Locale pack demo',
ko: 'Locale pack demo',
};
export const options = {
ariaLabel: LABELS.ja,
columns: [
{ id: 'sku', title: 'SKU', width: 100 },
{ id: 'qty', title: 'Qty', kind: 'number', width: 90, align: 'end', aggregate: 'sum' },
{ id: 'price', title: 'Price', kind: 'number', width: 100, align: 'end', aggregate: 'sum' },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
pagination: { mode: 'client', pageSize: 5 },
filterRow: true,
columnMenu: true,
summary: true,
// Give the pack to this grid only (no globals). With the npm package, register it once with registerLocale(pack) and every grid uses it.
locale: 'ja',
localePacks: [ja],
};
export const actions = {
// Changing only locale makes the pager, filter row, column menu and summary row text appear in the new language on the next screen update.
locale: (api, value = 'ja') => api.setOptions({ locale: value, ariaLabel: LABELS[value] ?? LABELS.en }),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Register a language pack and switch the grid language</title>
</head>
<body>
<div class="toolbar">
<select aria-label="Language" id="locale">
<option value="ja" selected>Japanese (small pack)</option>
<option value="en">English (built in)</option>
<option value="ko">Korean (built in)</option>
</select>
</div>
<div id="grid" style="height: 340px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// The table data is only codes and numbers, so it looks the same in any language. What changes is the text the grid itself uses.
const rows = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
sku: `A-${101 + i}`,
qty: 3 + ((i * 7) % 20),
price: 1200 + i * 350,
}));
const ja = {
code: 'ja',
messages: {
noRows: '表示する行がありません。',
loading: '読み込み中…',
columnMenuLabel: '列メニュー',
menuSortAsc: '昇順で並べ替え',
menuSortDesc: '降順で並べ替え',
menuHide: '列を非表示',
},
pager: {
nav: 'ページ送り',
first: '最初のページ',
previous: '前のページ',
next: '次のページ',
last: '最後のページ',
pageNumber: '{page}ページ',
pageSize: '1ページの行数',
summary: '全{total}件中 {from}–{to}件',
empty: '表示する行がありません',
},
filter: {
rowLabel: 'フィルター',
inputLabel: '{title}で絞り込み',
clearAll: 'すべてのフィルターを解除',
clearOne: '{title}のフィルターを解除',
all: 'すべて',
},
text: { summaryTotal: '合計', selectAll: 'すべて選択' },
};
// The grid's accessible name (ariaLabel) also changes to the chosen language.
const LABELS = {
ja: 'ロケールパックのデモ',
en: 'Locale pack demo',
ko: 'Locale pack demo',
};
const options = {
ariaLabel: LABELS.ja,
columns: [
{ id: 'sku', title: 'SKU', width: 100 },
{ id: 'qty', title: 'Qty', kind: 'number', width: 90, align: 'end', aggregate: 'sum' },
{ id: 'price', title: 'Price', kind: 'number', width: 100, align: 'end', aggregate: 'sum' },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
pagination: { mode: 'client', pageSize: 5 },
filterRow: true,
columnMenu: true,
summary: true,
// Give the pack to this grid only (no globals). With the npm package, register it once with registerLocale(pack) and every grid uses it.
locale: 'ja',
localePacks: [ja],
};
const actions = {
// Changing only locale makes the pager, filter row, column menu and summary row text appear in the new language on the next screen update.
locale: (api, value = 'ja') => api.setOptions({ locale: value, ariaLabel: LABELS[value] ?? LABELS.en }),
};
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('locale').addEventListener('change', (event) => actions.locale(api, event.target.value));
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
return (
<>
<div className="toolbar">
<select
aria-label="Language"
disabled={!api}
onChange={(event) => api && actions.locale(api, event.target.value)}
>
<option value="ja">Japanese (small pack)</option>
<option value="en">English (built in)</option>
<option value="ko">Korean (built in)</option>
</select>
</div>
<Grid style={{ height: 340 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions, LocalePack } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
sku: string;
qty: number;
price: number;
}
// The table data is only codes and numbers, so it looks the same in any language. What changes is the text the grid itself uses.
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
sku: `A-${101 + i}`,
qty: 3 + ((i * 7) % 20),
price: 1200 + i * 350,
}));
// A small Japanese pack. A full pack fills every key of the translation template and is verified with checkLocalePack (see the guide).
// Here only some keys are provided, to show that missing keys fall back to English. Example: the rest of the column menu items, the filter popup.
type Partial4<T extends LocalePack> = { code: string } & {
[S in 'messages' | 'pager' | 'filter' | 'text']: Partial<T[S]>;
};
const ja: Partial4<LocalePack> = {
code: 'ja',
messages: {
noRows: '表示する行がありません。',
loading: '読み込み中…',
columnMenuLabel: '列メニュー',
menuSortAsc: '昇順で並べ替え',
menuSortDesc: '降順で並べ替え',
menuHide: '列を非表示',
},
pager: {
nav: 'ページ送り',
first: '最初のページ',
previous: '前のページ',
next: '次のページ',
last: '最後のページ',
pageNumber: '{page}ページ',
pageSize: '1ページの行数',
summary: '全{total}件中 {from}–{to}件',
empty: '表示する行がありません',
},
filter: {
rowLabel: 'フィルター',
inputLabel: '{title}で絞り込み',
clearAll: 'すべてのフィルターを解除',
clearOne: '{title}のフィルターを解除',
all: 'すべて',
},
text: { summaryTotal: '合計', selectAll: 'すべて選択' },
};
// The grid's accessible name (ariaLabel) also changes to the chosen language.
const LABELS: Record<string, string> = {
ja: 'ロケールパックのデモ',
en: 'Locale pack demo',
ko: 'Locale pack demo',
};
export const options: GridOptions<Row> = {
ariaLabel: LABELS.ja,
columns: [
{ id: 'sku', title: 'SKU', width: 100 },
{ id: 'qty', title: 'Qty', kind: 'number', width: 90, align: 'end', aggregate: 'sum' },
{ id: 'price', title: 'Price', kind: 'number', width: 100, align: 'end', aggregate: 'sum' },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
pagination: { mode: 'client', pageSize: 5 },
filterRow: true,
columnMenu: true,
summary: true,
// Give the pack to this grid only (no globals). With the npm package, register it once with registerLocale(pack) and every grid uses it.
locale: 'ja',
localePacks: [ja as LocalePack],
};
export const actions = {
// Changing only locale makes the pager, filter row, column menu and summary row text appear in the new language on the next screen update.
locale: (api: GridApi<Row>, value = 'ja') =>
api.setOptions({ locale: value, ariaLabel: LABELS[value] ?? LABELS.en }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
}
</script>
<template>
<div class="toolbar">
<select
aria-label="Language"
:disabled="!api"
@change="api && actions.locale(api, ($event.target as HTMLSelectElement).value)"
>
<option value="ja" selected>Japanese (small pack)</option>
<option value="en">English (built in)</option>
<option value="ko">Korean (built in)</option>
</select>
</div>
<Grid style="height: 340px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions, LocalePack } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
sku: string;
qty: number;
price: number;
}
// The table data is only codes and numbers, so it looks the same in any language. What changes is the text the grid itself uses.
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
sku: `A-${101 + i}`,
qty: 3 + ((i * 7) % 20),
price: 1200 + i * 350,
}));
// A small Japanese pack. A full pack fills every key of the translation template and is verified with checkLocalePack (see the guide).
// Here only some keys are provided, to show that missing keys fall back to English. Example: the rest of the column menu items, the filter popup.
type Partial4<T extends LocalePack> = { code: string } & {
[S in 'messages' | 'pager' | 'filter' | 'text']: Partial<T[S]>;
};
const ja: Partial4<LocalePack> = {
code: 'ja',
messages: {
noRows: '表示する行がありません。',
loading: '読み込み中…',
columnMenuLabel: '列メニュー',
menuSortAsc: '昇順で並べ替え',
menuSortDesc: '降順で並べ替え',
menuHide: '列を非表示',
},
pager: {
nav: 'ページ送り',
first: '最初のページ',
previous: '前のページ',
next: '次のページ',
last: '最後のページ',
pageNumber: '{page}ページ',
pageSize: '1ページの行数',
summary: '全{total}件中 {from}–{to}件',
empty: '表示する行がありません',
},
filter: {
rowLabel: 'フィルター',
inputLabel: '{title}で絞り込み',
clearAll: 'すべてのフィルターを解除',
clearOne: '{title}のフィルターを解除',
all: 'すべて',
},
text: { summaryTotal: '合計', selectAll: 'すべて選択' },
};
// The grid's accessible name (ariaLabel) also changes to the chosen language.
const LABELS: Record<string, string> = {
ja: 'ロケールパックのデモ',
en: 'Locale pack demo',
ko: 'Locale pack demo',
};
export const options: GridOptions<Row> = {
ariaLabel: LABELS.ja,
columns: [
{ id: 'sku', title: 'SKU', width: 100 },
{ id: 'qty', title: 'Qty', kind: 'number', width: 90, align: 'end', aggregate: 'sum' },
{ id: 'price', title: 'Price', kind: 'number', width: 100, align: 'end', aggregate: 'sum' },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
pagination: { mode: 'client', pageSize: 5 },
filterRow: true,
columnMenu: true,
summary: true,
// Give the pack to this grid only (no globals). With the npm package, register it once with registerLocale(pack) and every grid uses it.
locale: 'ja',
localePacks: [ja as LocalePack],
};
export const actions = {
// Changing only locale makes the pager, filter row, column menu and summary row text appear in the new language on the next screen update.
locale: (api: GridApi<Row>, value = 'ja') =>
api.setOptions({ locale: value, ariaLabel: LABELS[value] ?? LABELS.en }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<select
aria-label="Language"
[disabled]="!api"
(change)="api && actions.locale(api, $any($event.target).value)"
>
<option value="ja" selected>Japanese (small pack)</option>
<option value="en">English (built in)</option>
<option value="ko">Korean (built in)</option>
</select>
</div>
<mx-grid style="height: 340px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
}
}
}import type { GridApi, GridOptions, LocalePack } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
sku: string;
qty: number;
price: number;
}
// The table data is only codes and numbers, so it looks the same in any language. What changes is the text the grid itself uses.
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
sku: `A-${101 + i}`,
qty: 3 + ((i * 7) % 20),
price: 1200 + i * 350,
}));
// A small Japanese pack. A full pack fills every key of the translation template and is verified with checkLocalePack (see the guide).
// Here only some keys are provided, to show that missing keys fall back to English. Example: the rest of the column menu items, the filter popup.
type Partial4<T extends LocalePack> = { code: string } & {
[S in 'messages' | 'pager' | 'filter' | 'text']: Partial<T[S]>;
};
const ja: Partial4<LocalePack> = {
code: 'ja',
messages: {
noRows: '表示する行がありません。',
loading: '読み込み中…',
columnMenuLabel: '列メニュー',
menuSortAsc: '昇順で並べ替え',
menuSortDesc: '降順で並べ替え',
menuHide: '列を非表示',
},
pager: {
nav: 'ページ送り',
first: '最初のページ',
previous: '前のページ',
next: '次のページ',
last: '最後のページ',
pageNumber: '{page}ページ',
pageSize: '1ページの行数',
summary: '全{total}件中 {from}–{to}件',
empty: '表示する行がありません',
},
filter: {
rowLabel: 'フィルター',
inputLabel: '{title}で絞り込み',
clearAll: 'すべてのフィルターを解除',
clearOne: '{title}のフィルターを解除',
all: 'すべて',
},
text: { summaryTotal: '合計', selectAll: 'すべて選択' },
};
// The grid's accessible name (ariaLabel) also changes to the chosen language.
const LABELS: Record<string, string> = {
ja: 'ロケールパックのデモ',
en: 'Locale pack demo',
ko: 'Locale pack demo',
};
export const options: GridOptions<Row> = {
ariaLabel: LABELS.ja,
columns: [
{ id: 'sku', title: 'SKU', width: 100 },
{ id: 'qty', title: 'Qty', kind: 'number', width: 90, align: 'end', aggregate: 'sum' },
{ id: 'price', title: 'Price', kind: 'number', width: 100, align: 'end', aggregate: 'sum' },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
pagination: { mode: 'client', pageSize: 5 },
filterRow: true,
columnMenu: true,
summary: true,
// Give the pack to this grid only (no globals). With the npm package, register it once with registerLocale(pack) and every grid uses it.
locale: 'ja',
localePacks: [ja as LocalePack],
};
export const actions = {
// Changing only locale makes the pager, filter row, column menu and summary row text appear in the new language on the next screen update.
locale: (api: GridApi<Row>, value = 'ja') =>
api.setOptions({ locale: value, ariaLabel: LABELS[value] ?? LABELS.en }),
};