Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions testapps/react/src/components/Namespaces.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { useTranslate, T } from '@tolgee/react';

// Declared inline so the tolgee-cli extractor can resolve `NS.NAMESPACED` —
// cross-file resolution is not yet supported. See ../i18n/namespaces.ts for
// the shared definition (mirror this entry there when adding new namespaces).
const NS = { NAMESPACED: 'namespaced' } as const;

export const Namespaces = () => {
const { t } = useTranslate('namespaced');
const { t } = useTranslate(NS.NAMESPACED);

return (
<div className="tiles namespaces">
Expand All @@ -18,7 +23,7 @@ export const Namespaces = () => {
<div>
<h1>T component with namespace</h1>
<div>
<T keyName="this_is_a_key" ns="namespaced" />
<T keyName="this_is_a_key" ns={NS.NAMESPACED} />
</div>
</div>
</div>
Expand Down
14 changes: 14 additions & 0 deletions testapps/react/src/i18n/namespaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Single source of truth for namespace identifiers used in this app.
*
* The Tolgee CLI extractor resolves `const NS = { ... } as const` references
* within a single file, but it does NOT yet follow imports. Until cross-file
* resolution lands, consumers (e.g. components/Namespaces.tsx) must also
* declare an inline `const NS` mirroring the entries used in that file.
* Keep this file as the authoritative list and mirror entries on demand.
*/
export const NS = {
NAMESPACED: 'namespaced',
} as const;

export type Namespace = (typeof NS)[keyof typeof NS];
Loading