logologo
Get Started
Guide
Development
Plugins
API
English
简体中文
Get Started
Guide
Development
Plugins
API
English
简体中文
logologo

Quick Start

Plugin Development Overview
Write Your First Plugin
Project Structure

Server Development

Overview
Plugin
Collections
Database
DataSourceManager
ResourceManager
ACL
Middleware
Cache
Event
Context
Migration
Logger
I18n
Command
CronJobManager
Test

Client Development

Overview
Plugin
Context
Router
ACL
DataSourceManager
Resource
Request
Styles & Themes
Logger
I18n
Test

Others

Plugin Upgrade Guide
Languages
Dependency Management
Build
Previous PageLogger
Next PageTest

#I18n

NocoBase plugins support multi-language internationalization (i18n) for both frontend and backend. Through a unified mechanism, you can easily implement multi-language content in plugins.

#Multi-language File Management

Plugin multi-language files are uniformly stored in the src/locale directory. It's recommended to name them by language, for example:

|- /plugin-hello
  |- /src
    |- /locale
      |- en-US.json   # English language
      |- zh-CN.json   # Chinese language

Each language file exports a JSON object containing all translation entries for that language, for example:

// zh-CN.json
{
  "Hello": "你好",
  "World": "世界",
  "Enter your name": "请输入你的名字",
  "Your name is {{name}}": "你的名字是 {{name}}"
}
// en-US.json
{
  "Hello": "Hello",
  "World": "World",
  "Enter your name": "Enter your name",
  "Your name is {{name}}": "Your name is {{name}}"
}

When adding language files for the first time, you need to restart the application for them to take effect. You can verify that the translation entries have taken effect through the API:
http://localhost:13000/api/app:getLang?locale=zh-CN

#i18n Related APIs

#ctx.i18n

#ctx.t(text, options)

#plugin.t()

#useT()

#tExpr(text)

#useTranslation(ns)

#withTranslation(ns)