Skip to content
better-i18n.com
本页内容

Read endpoints answer in a compact shape: short field names, and namespaces stored once per page instead of once per key.

The same endpoints back the MCP servers, where the abbreviation cuts token use by roughly half. The Admin SDK returns them unchanged rather than maintaining a second wire format, so keys.list() gives you k, not keys.

keys.list() #

TypeScript
const res = await admin.keys.list({ limit: 50 });

for (const key of res.k) {
  console.log(res.nss[key.ns], key.k); // "common", "auth.login.title"
}
FieldTypeMeaning
totnumberTotal matching keys, before pagination
retnumberKeys returned on this page
pgnumberCurrent page, 1 indexed
limnumberPage size
has_morebooleanMore pages exist, increment pg
nssstring[]Namespace lookup table
karrayThe keys, see below
notestring?Hint, for example a large-project warning

Each entry in k:

FieldTypeMeaning
kstringKey name
nsnumberIndex into nss, not a namespace string
idstring?Key UUID, when "id" is in fields
srcstring?Source text, when "sourceText" is in fields
tlstring[]?Language codes that have a translation
tlcnumber?Count of translated languages, cheaper than tl
trobject?Translations, when "translations" is in fields
ptrue?Phantom key, a legacy duplicate worth deleting

fields defaults to ["id", "sourceText"]. Ask for translations only when you need the text, since it dominates the response size.

translations.get() #

FieldTypeMeaning
prjstringProject slug
slstringSource language code
ret / totnumberReturned, and total before pagination
has_morebooleanMore results exist
keysarray{ id, k, ns?, src, tr? } per key
srch / lng / stEcho of the search, languages and status filters
nsdobject?Namespace descriptions
hintstring?Set when a filter was ignored, read it

Pass compact: true to get counts instead of text: each key becomes { id, k, ns?, tc } where tc is the translation count.

translations.pendingChanges() #

FieldTypeMeaning
has_chgbooleanAnything waiting to publish
sumobject{ tr, del_k, lng_chg, tot } counts by kind
by_lngobjectPending counts per language
del_karrayKeys deleted but not yet published
pub_dststringWhere a publish would go
no_pub_rsnstring?Why publishing is currently blocked

sync.list() and sync.get() #

list() returns { prj, tot, sy: [...] }. Each job:

FieldMeaning
idSync job ID
tpJob type
stStatus
st_at / cp_atStarted at, completed at
err_msgFailure reason
trig_byWhat triggered it
meta{ kp, tf?, pf? } keys processed, target and pushed files

get() adds log and aff_k, the affected keys as { k, act } pairs.

Write endpoints #

Writes answer with a receipt rather than the object you sent:

MethodShape
keys.create(){ ok, cnt, new, ren, dup, k: [{ k, id, tr }], skip?, warn?, blocked?, hint? }
keys.update(){ ok, cnt, upd: [{ id?, k, lng, src }], errors?, hint? }
keys.delete(){ ok, cnt, mk: [{ id, k, ns }], skip?, hint? }
translations.set(){ ok, cnt, wrote, upd: [{ id, k, lng }], errors?, hint? }

cnt is what the call touched, errors is per item, so a partial success is visible instead of being reported as a failure.

Always read hint and warn #

Several endpoints return a hint when a filter was silently ignored, or a warn when a write collided with something in another namespace. They are the only signal that a call did less than you asked.

TypeScript
const res = await admin.keys.create({ k: [{ n: "cta.title", v: "Get started" }] });
if (res.warn) console.warn(res.warn);