Skip to content

Using Dictionaries

Dictionaries are traditional key-value translation files. They’re useful for:

  • Shared strings across many components (button labels, error messages)
  • Content managed outside your codebase
  • Migration from existing i18n setups
{
"dictionaries": {
"include": ["src/dictionaries/*.json"],
"format": "key-value"
}
}
src/dictionaries/common.json
{
"save": "Save",
"cancel": "Cancel",
"delete": "Delete",
"loading": "Loading..."
}

useDictionary(filenameKey) looks up one dictionary file and returns a Record<string, string>. The filename key is the dictionary path without the .json extension:

  • src/dictionaries/common.jsoncommon
  • src/dictionaries/pages/home.jsonpages/home
import { useDictionary } from 'tyndale-react';
export function ActionButtons() {
const labels = useDictionary('common');
return (
<div>
<button>{labels.save ?? 'Save'}</button>
<button>{labels.cancel ?? 'Cancel'}</button>
</div>
);
}

If no entries match the filename key, useDictionary(filenameKey) returns an empty object.