Skip to content

Commit

Permalink
Show translation key if no translation is available
Browse files Browse the repository at this point in the history
  • Loading branch information
Falke-Design committed Mar 24, 2024
1 parent fd4205c commit 16fb6b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions cypress/integration/tooltips.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,15 @@ describe('Shows Tooltips', () => {
);
});
});

it('shows key if no translation is available', () => {
cy.window().then(({ L }) => {
expect(L.PM.Utils.getTranslation('tooltips.placeMarker')).to.eq(
'Click to place marker'
);
expect(L.PM.Utils.getTranslation('tooltips.mytext')).to.eq(
'tooltips.mytext'
);
});
});
});
2 changes: 1 addition & 1 deletion src/js/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import translations from '../../assets/translations';
export function getTranslation(path) {
const lang = L.PM.activeLang;
// if translation is not found, fallback to english
return get(translations[lang], path) || get(translations.en, path);
return get(translations[lang], path) || get(translations.en, path) || path;
}

export function hasValues(list) {
Expand Down

0 comments on commit 16fb6b4

Please sign in to comment.