Skip to content

Commit ff6ddec

Browse files
committed
document translation key retrieval
1 parent 21014bd commit ff6ddec

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/translation.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ If you're making a new Component and adding Translation Keys for your Component,
6060
- Translation Keys should be in Camel Case only.
6161
- The values of each Translation Key should follow the [ICU Message Syntax](https://next-intl-docs.vercel.app/docs/usage/messages#rendering-icu-messages)
6262
- All new Translation keys should be added at the bottom of the `i18n/locales/en.json` file. Since this makes it easier for Translators to notice that there are new Translation keys to be translated.
63+
- Reference the full path to the key within your Component. This helps with static analysis, even at the cost of verbosity. For example:
64+
65+
```tsx
66+
const t = useTranslations('components.common.myComponent');
67+
t('copyButton.title');
68+
const t = useTranslations();
69+
t('components.common.myComponent.copyButton.title');
70+
```
6371

6472
#### Notes about Translation Keys
6573

0 commit comments

Comments
 (0)