Skip to content

Commit

Permalink
Fallback code for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
strseb committed Aug 30, 2024
1 parent 4075998 commit 1c36497
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/shared/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
* @returns The Message translated for the Users Language.
*/
export const tr = (id, ...arg) => {
const candidate = browser.i18n.getMessage(id, arg);
if (!candidate || candidate.length === 0) {
console.error(`Missing Translation Message for ${id}`);
try {
const candidate = browser.i18n.getMessage(id, arg);
if (!candidate || candidate.length === 0) {
console.error(`Missing Translation Message for ${id}`);
return id;
}
return candidate;
} catch (error) {
return id;
}
return candidate;
};

0 comments on commit 1c36497

Please sign in to comment.