nocobase-app-plugin-i18n
できること
NocoBase 3のアプリやプラグインで、翻訳されたテキストを追加または変更する作業を案内します。アプリを複数の言語に対応させたい開発者向けです。
使う場面
- ✓複数の言語で表示する必要がある、新しいラベル、ボタン、メッセージを追加するとき。
- ✓受信者の言語で、サーバーのエラーやメールを翻訳する必要があるとき。
- ✓すでにロケールファイルがあるパッケージに、新しい言語を追加したいとき。
スキルのリンク
https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-i18n/skills/nocobase-app-plugin-i18n/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のNocoBaseアプリの新しい「保存」ボタンとエラーメッセージを、ポルトガル語とスペイン語に翻訳してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIは、正しいlocalesファイルと名前空間に、テキストを翻訳キーの背後に置きます。そのうえで、ブラウザまたはサーバーで翻訳用のヘルパーを使って表示します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Goal
Put user-facing text behind a translation key correctly the first time: in the right file, under the right namespace, and in a way that survives a language switch.
Scope
- Wire locale files into a package that has none yet.
- Add a string to an application or a plugin and render it translated, in the browser or on the server.
- Throw an error that callers see in their own language, and translate mail or jobs for their recipient.
- Add a language to a package that already has locale files.
- Reword a plugin's copy from the application, without editing the plugin.
- Translate a menu or breadcrumb title.
Non-Goals
- Do not build a language picker.
useAppLocale()exists;app-template-defaultalready renders one inclient/layouts/components/language-switcher.tsx. - Do not add i18n machinery to an application. The plugin is registered by default, the client runtime is built by
createAppI18nRuntime, and the server's byI18nProvider. - Do not configure the list of languages. It is whatever the application's own
locales/index.tsdeclares; configuration names only the default,i18n.defaultLocale(overridden byAPP_DEFAULT_LOCALE). The@nocobase/app-plugin-i18nREADME covers that,useAppLocale(), the endpoints, anduseSyncServerLocale(), which the template shell already calls to keep the server's language in step with the browser's.
The one rule that decides everything
A namespace is a package name, and the namespace in scope follows the render tree.
An application's pages get the application's namespace; a plugin's pages get that plugin's, because the host wraps each contribution using the packageName it already records. So a component in its own package's routes translates with no namespace at all.
The exception is what most mistakes come from: a component a plugin exports for the application to render is in the application's scope, not its own. It has to name its namespace.
Procedure
Wiring locales into a package for the first time
A package has a client/locales/ and a server/locales/ tree, each with an en-US.ts, the other languages, and an index.ts mapping every language to a dynamic import:
// client/locales/index.ts, and server/locales/index.ts in the same shape
import type { LocaleLoaders } from '@nocobase/i18n';
const locales: LocaleLoaders = {
'en-US': () => import('./en-US.js'),
'zh-CN': () => import('./zh-CN.js'),
};
export default locales;
Import that module and pass it as locales, the same way on both sides:
// client/plugin.ts
import locales from './locales/index.js';
export default defineClientPlugin({
packageName: '@acme/app-plugin-orders',
locales,
routes,
});
// server/plugin.ts
import locales from './locales/index.js';
export default defineServerPlugin({
baseDir,
packageName: '@acme/app-plugin-orders',
locales,
});
Import it statically. Each language is already a separate dynamic import, so a language is loaded only when something needs it; deferring the map as well gains nothing. locales: () => import('./locales/index.js') is still accepted on both sides for code written that way.
Without this step every t() in the package renders its key. An application's own client/runtime.ts and server/runtime.ts pass their locales the same way.
Adding a string
- Find the package that owns the text. Application text goes in
client/locales/; a plugin's text goes in that plugin'sclient/locales/. - Add the key to
en-US.ts. The structure is written once: the type is derived from the value withLocaleResource<typeof enUS>, and other locales are annotated with it, which is what makes a typo a compile error. - Add the translation to every other locale file. A missing key falls back rather than breaking, so this can lag, and
typecheckreports it. - Render it with
useTranslationfrom@nocobase/i18n/client.
import { useTranslation } from '@nocobase/i18n/client';
const { t } = useTranslation();
t('actions.save');
Keys nest and are addressed with dots: t('trigger.types.schedule').
Naming translation keys
Use short semantic keys that describe the purpose of the text and stay valid when its wording changes. Use lower camelCase within each segment and dots for useful feature or context groups, such as files.uploadFailed or demo.pageDescription. A small namespace may use title directly. Do not use complete English sentences as keys or merely convert a sent
よくある質問
言語を切り替える画面を追加しますか?
いいえ。アプリのテンプレートにはすでに含まれており、このスキルは別のものを追加しません。
対応言語はどこに記載されますか?
アプリ自身のlocalesファイルに記載されます。
このスキルは何に重点を置きますか?
テキストを翻訳キーの背後に置き、言語を切り替えても正しく表示されるように、適切なファイルに入れることです。
詳細
作者による元の説明
Use when adding or changing user-facing text in a NocoBase application or plugin: writing locale files, wiring a package's locales for the first time, translating a component or a menu title, naming a namespace, translating server responses, errors and outbound mail, or adding a language. Not for building page UI around the text (nocobase-app-development) or scaffolding a new plugin (nocobase-app-plugin-development); those Skills hand translation work here.
repo: nocobase/nocobase
人気
- GitHubのスター
- 25k
- ランキング
- #10099
- ライセンス
- —
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
nocobase-app-development
25kエージェントが、NocoBase 3の完全なビジネスアプリケーションのために、ページ、ルーティング、データ、権限、テストを作れるよう支援します。
shadcn
25kエージェントが、公式のドキュメントとレジストリを使い、Webプロジェクトの shadcn/uiコンポーネントを見つけ、追加し、修正し、スタイルを整えられるよう支援します。
nocobase-app-plugin-development
25kエージェントが、既存のNocoBase 3アプリの中で、サーバー、クライアント、データベース、登録の部分を含むプラグインを作成し、保守できるよう支援します。
nocobase-app-upgrade
25kエージェントが、NocoBaseのアプリを新しいテンプレートのリリースにアップグレードし、テンプレートの変更を取り込みつつ、あなた自身の作業を保てるよう支援します。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。