MetaMask / MetaMask/metamask-extension
[Sentry] WARNING: `Translator - Unable to find value of key "${key}" for locale "${localeCode}"`,
@DDDDDanica is already working on this.
Since Sep 7, 2023.
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
Sentry warning: METAMASK-PVS3
Private Zenhub Image
Currently we will throw error when we have missing value for new added locale key, which happens all the time, because we will rely on such automation Crowdin MR from bot to help to merge the missing value, and there will always be a gap between production and current translated locales.
What we want to achieve is to not only removing warning from sentry report, but handle the error elegantly.
We can change the approach by make modifications in the log.warn we have at the moment in following helper function:
function missingKeyError(
key: string,
localeCode: string,
onError?: (error: Error) => void,
) {
if (localeCode === FALLBACK_LOCALE && !missingMessageErrors[key]) {
const error = new Error(
`Unable to find value of key "${key}" for locale "${localeCode}"`,
);
missingMessageErrors[key] = error;
onError?.(error);
log.error(error);
if (process.env.IN_TEST) {
throw error;
}
}
if (localeCode === FALLBACK_LOCALE || warned[localeCode]?.[key]) {
return;
}
warned[localeCode] = warned[localeCode] ?? {};
warned[localeCode][key] = true;
// ----- we can return a new value/undefined here,
log.warn(
`Translator - Unable to find value of key "${key}" for locale "${localeCode}"`,
);
}
Proposal:
- Return
envalue when key is not found
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.