🚀 Feature Proposal
i18next-cli extract handles static literals well but misses many finite dynamic keys that are inferable from TypeScript types.
Motivation
Without built-in type-aware resolution, teams need custom TypeScript pre-pass scripts and synthetic files to extract keys that are still statically finite.
Examples of finite dynamic patterns:
-
t(\${prefix}_${variant}`)wherevariant` is a string-literal union
-
t(\${name}Suffix`)wherename` is a const/union
-
t(getGreetingKey()) where a helper returns a finite set of literals
-
t(map[type]) where map is as const
I'm aware there is extract.preservePatterns option, but it would be good to have a general extraction capability rather than hard-coding project-specific patterns.
Example
type ChangeType = 'all' | 'next' | 'this';
const t = i18next.t;
function key(): 'goodMorning' | 'goodEvening' {
return Math.random() > 0.5 ? 'goodMorning' : 'goodEvening';
}
const map = { all: 'allAccess', next: 'nextAccess' } as const;
declare const type: ChangeType;
t(`prefix_${type}`);
t(key());
t(map[type]);