Repository navigation
Internationalization
oCMS includes a comprehensive internationalization system for the admin interface, modules, and themes.
The i18n system supports:
- Admin interface translations
- Module-embedded translations
- Theme-level translation overrides
- Multiple languages (English, Russian by default)
- JSON Schema validation for translation files
{
"$schema": "../../../../.schema/i18n-schema.json",
"language": "en",
"messages": [
{
"id": "module.key",
"message": "Original text (English)",
"translation": "Translated text"
}
]
}| Field | Required | Description |
|---|---|---|
$schema |
No | Path to JSON schema for validation |
language |
Yes | ISO 639-1 language code |
messages |
Yes | Array of translation entries |
messages[].id |
Yes | Unique identifier using dot notation |
messages[].message |
No | Original text (for reference) |
messages[].translation |
Yes | Translated text |
Translation IDs use dot notation: {namespace}.{category}.{key}
Examples:
-
hcaptcha.title— Module title -
analytics_ext.ga4_measurement_id— Form field label -
nav.dashboard— Navigation item -
frontend.read_more— Frontend string
Located in internal/i18n/locales/:
internal/i18n/locales/
├── en/messages.json
└── ru/messages.json
Modules embed their own translations. See Module System for details.
modules/mymodule/
├── module.go
└── locales/
├── en/messages.json
└── ru/messages.json
Embed and expose via TranslationsFS():
//go:embed locales
var localesFS embed.FS
func (m *Module) TranslationsFS() embed.FS {
return localesFS
}Themes can override global translations for frontend strings. See Theme System for details.
custom/themes/mytheme/
└── locales/
├── en/messages.json
└── ru/messages.json
| Function | Use Case | Fallback |
|---|---|---|
TTheme |
Theme templates (frontend) | Theme → Global |
T |
Admin templates, modules | Global only |
<!-- Theme template -->
<a href="{{.URL}}">{{TTheme .LangCode "frontend.read_more"}}</a>
<!-- Admin template -->
<h1>{{T .AdminLang "mymodule.title"}}</h1>import "github.com/olegiv/ocms-go/internal/i18n"
message := i18n.T(lang, "mymodule.success_save")-
Create language directories in core and each module:
mkdir -p internal/i18n/locales/de mkdir -p modules/hcaptcha/locales/de
-
Copy English files as templates and translate
-
Update the
languagefield in each file -
Add the language code to
SupportedLanguagesininternal/i18n/i18n.goand rebuild; translations for a code not listed there are never loaded -
Register the language in the database (Admin > Languages) so that it is active and appears in the admin language selector
The project includes a JSON schema at .schema/i18n-schema.json.
Add to .vscode/settings.json:
{
"json.schemas": [
{
"fileMatch": ["**/locales/*/messages.json"],
"url": "./.schema/i18n-schema.json"
}
]
}- Use lowercase with dots as separators for IDs
- Start with module/namespace name
- Group related translations (
module.error_*,module.success_*, etc.) - Keep translations concise
- Consider text expansion for longer languages
- Use placeholders for dynamic content:
"Welcome, %s" - Keep message order consistent across languages
| Code | Language |
|---|---|
en |
English |
ru |
Russian |
See Multi-Language for content translation (as opposed to UI translation).
Getting Started
Core Features
- Content Management
- Media Library
- Taxonomy
- Menu Builder
- Forms
- Multi-Language
- SEO
- Feeds
- Video Embedding
- Agent-Ready
Administration
API & Integrations
Security
Theme Development
Module Development
Built-in Modules
- Module: Sentinel
- Module: Developer
- Module: DB Manager
- Module: Migrator
- Module: Informer
- Module: Demo Mode
- Module: Internal Analytics
- Module: External Analytics
- Module: Privacy
- Module: Embed
- Module: MCP Server
Deployment