• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zooniverse / front-end-monorepo / 12334823867

15 Dec 2024 01:47AM UTC coverage: 77.373% (+0.02%) from 77.354%
12334823867

Pull #6553

github

web-flow
Merge 32f1ac7a3 into 3e8f2ee55
Pull Request #6553: lib-user: Setup react-i18next for Contributors components

10736 of 16057 branches covered (66.86%)

Branch coverage included in aggregate %.

15 of 20 new or added lines in 4 files covered. (75.0%)

62 existing lines in 12 files now uncovered.

16788 of 19516 relevant lines covered (86.02%)

410.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/packages/lib-user/src/translations/i18n.js
1
import i18n from 'i18next'
1✔
2
import {
1✔
3
  initReactI18next,
4
  Trans as BaseTrans,
5
  useTranslation as useBaseTranslation
6
} from 'react-i18next'
2!
7

8
const libI18n = i18n.createInstance()
1✔
9
libI18n.use(initReactI18next).init({
1✔
10
  fallbackLng: 'en',
11
  interpolation: {
12
    escapeValue: false // not needed for react as it escapes by default
13
  },
14
  react: {
15
    useSuspense: false
16
  }
17
})
18

19
libI18n.addResourceBundle('en', 'translation', require('./en.json'))
1✔
20

21
/* In FEM there's an i18n instance for each library, and each instance has its own functions.*/
22
export function useTranslation(ns) {
23
  return useBaseTranslation(ns, { i18n: libI18n })
168✔
24
}
25

26
export function withTranslation(ns) {
NEW
27
  return Component => {
×
NEW
28
    return function TranslatedComponent(props) {
×
NEW
29
      const { t } = useTranslation(ns)
×
NEW
30
      return <Component i18n={libI18n} t={t} {...props} />
×
31
    }
32
  }
33
}
34

35
export function Trans(props) {
NEW
36
  return <BaseTrans {...props} i18n={libI18n}/>
×
37
}
1✔
38

39
export default i18n
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc