How to use the cozy-ui/transpiled/react/I18n/translation.initTranslation function in cozy-ui

To help you get started, we’ve selected a few cozy-ui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cozy / cozy.github.io / en / cozy-banks / src / ducks / notifications / services.js View on Github external
import BalanceLower from './BalanceLower'
import TransactionGreater from './TransactionGreater'
import HealthBillLinked from './HealthBillLinked'
import LateHealthReimbursement from './LateHealthReimbursement'
import DelayedDebit from './DelayedDebit'

import { BankAccount } from 'models'
import { sendNotification } from 'cozy-notifications'
import { GROUP_DOCTYPE } from 'doctypes'
import get from 'lodash/get'

const log = logger.namespace('notification-service')

const lang = process.env.COZY_LOCALE || 'en'
const dictRequire = lang => require(`../../locales/${lang}`)
const translation = initTranslation(lang, dictRequire)
const t = translation.t.bind(translation)

const notificationClasses = [
  BalanceLower,
  TransactionGreater,
  HealthBillLinked,
  LateHealthReimbursement,
  DelayedDebit
]

const setDifference = (a, b) => {
  return new Set([...a].filter(x => !b.has(x)))
}

export const fetchTransactionAccounts = async transactions => {
  const accountsIds = new Set(transactions.map(x => x.account))
github cozy / cozy.github.io / en / cozy-banks / src / ducks / notifications / LateHealthReimbursement / index.spec.js View on Github external
const setup = ({ lang }) => {
    const localeStrings = require(`locales/${lang}.json`)
    const {
      initTranslation
    } = require('cozy-ui/transpiled/react/I18n/translation')
    const translation = initTranslation(lang, () => localeStrings)
    const t = translation.t.bind(translation)
    const notification = new LateHealthReimbursement({
      t,
      data: {},
      lang: 'en',
      locales: {
        en: localeStrings
      },
      client: { stackClient: { uri: 'http://cozy.tools:8080' } },
      value: 20
    })
    return { notification }
  }
  ;['fr', 'en'].forEach(lang => {