mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-08-17 12:40:30 +00:00
refactor(translateOption): use Sleeyax suggestion
This commit is contained in:
parent
567af0b83b
commit
32a7117493
1 changed files with 6 additions and 9 deletions
|
|
@ -4,15 +4,12 @@ const { t } = require('i18next');
|
|||
|
||||
const translateOption = (option, translateKeyPrefix = '') => {
|
||||
const translateKey = `${translateKeyPrefix}${option}`;
|
||||
const translateKeyUppercase = translateKey.toUpperCase();
|
||||
const translateValue = t(translateKey);
|
||||
const translateValueUppercase = t(translateKeyUppercase);
|
||||
if (translateKey !== translateValue) {
|
||||
return translateValue;
|
||||
} else if (translateKeyUppercase !== translateValueUppercase) {
|
||||
return translateValueUppercase;
|
||||
}
|
||||
return option.charAt(0).toUpperCase() + option.slice(1);
|
||||
const translateValue = t(translateKey, {
|
||||
defaultValue: t(translateKey.toUpperCase(), {
|
||||
defaultValue: null
|
||||
})
|
||||
});
|
||||
return translateValue ?? option.charAt(0).toUpperCase() + option.slice(1);
|
||||
};
|
||||
|
||||
module.exports = translateOption;
|
||||
|
|
|
|||
Loading…
Reference in a new issue