How to extract missing translations?
bfontaine opened this issue · 4 comments
Hello,
Is there any way to parse the code and extract the missing translations for a locale? I’m looking for a gettext-like workflow where I just use $t('whatever')
in my code and then run a command to update the translation files with the new keys.
I didn’t find anything in the docs for that.
Thanks
Hi @bfontaine, if i understand you correctly, you want to iterate through defined translation keys and then update translation records in case of missing entry?
If so, i would do something like this:
-
First of all, i would iterate your translation keys using
$t('<CURRENT_KEY>', { default: 'undefined' })
(ort.get( ... )
) and collect all keys for'undefined'
(default) value. -
I would update translations for undefined keys either in your definition files or locally using
addTranslations
method.
Let me, please, know if it helped to you..
Hello, to clarify, I want a tool/command that I can run to statically extract all calls to $t(...)
from my code and add the missing keys in the translation files.
The workflow would look like this:
- Code, and use
$t("...")
where needed - Run
npm run extract-translations
- Let the translators know there are new translations to fill
Oh, Ok. Currently, there are no CLI tools to extract used translations..
Ok, thank you for the response!