All files / src/domain/i18n/useCases getText.ts

100% Statements 5/5
75% Branches 3/4
100% Functions 0/0
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23          2x       1x       1x       1x     3280x    
import currentLocale from '../../../constants/currentLocale';
import i18n from '../../../data/i18n.json';
 
export default function getText (group: string, item: string): string { // TODO: use enum for parameters
  if (!group || !item) {
    return '';
  }
 
  if (!i18n[currentLocale.locale]) {
    return '[missing locale data]';
  }
 
  if (!i18n[currentLocale.locale][group]) {
    return '[missing locale group data]';
  }
 
  if (!i18n[currentLocale.locale][group][item]) {
    return '[missing locale item data]';
  }
 
  return i18n[currentLocale.locale][group][item] || '';
}