MetaMask / MetaMask/metamask-extension

[Sentry] WARNING: `Translator - Unable to find value of key "${key}" for locale "${localeCode}"`,

Open
#20,777 0 comments 0 reactions 1 assignee View on GitHub

@DDDDDanica is already working on this.

Since Sep 7, 2023.

area-sentry product-backlog team-extension-platform
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:

  1. Return en value when key is not found

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.