Skip to content

togo-framework/translation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

togo

togo-framework/translation

marketplace pkg.go.dev MIT

Part of the togo framework.

Install

togo install togo-framework/translation

translation — DB-backed dynamic i18n for togo

A togo plugin that makes translations editable at runtime, in the database — no redeploy. It overrides the kernel translator (k.I18n): keys resolve from the DB first and fall back to the static i18n catalog (install togo-framework/i18n for the static fallback).

togo install togo-framework/i18n          # static catalog (fallback)
togo install togo-framework/translation   # DB-backed dynamic overrides

REST API

Method Path Body
GET /api/translations?locale=ar — → {key: value}
GET /api/translations/locales — → ["ar","en"]
PUT /api/translations/{locale}/{key} {"value":"..."}
DELETE /api/translations/{locale}/{key}
POST /api/translations/import {locale:{key:value}}

Go API

t := translation.FromKernel(k)
_ = t.Set(ctx, "ar", "welcome", "مرحبا")
msg := k.I18n.T("ar", "welcome")   // DB value, else the static catalog

Data model

translations(locale text, tkey text, value text, PRIMARY KEY (locale, tkey)), created on boot. An in-memory cache backs T() (refreshed on writes).

MIT


Premium sponsors

ID8 Media  ·  One Studio

Support togo — become a sponsor.

About

DB-backed dynamic i18n for togo — edit translations at runtime, falls back to the static i18n catalog

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors

Languages