How to use the @lingui/cli/api.configureCatalog function in @lingui/cli

To help you get started, we鈥檝e selected a few @lingui/cli 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 lingui / js-lingui / packages / loader / src / index.js View on Github external
// Webpack 4 uses json-loader automatically, which breaks this loader because it
  // doesn't return JSON, but JS module. This is a temporary workaround before
  // official API is added (https://github.com/webpack/webpack/issues/7057#issuecomment-381883220)
  // See https://github.com/webpack/webpack/issues/7057
  if (JavascriptParser && JavascriptGenerator) {
    this._module.type = "javascript/auto"
    this._module.parser = new JavascriptParser()
    this._module.generator = new JavascriptGenerator()
  }

  const config = getConfig({
    configPath: options.config,
    cwd: path.dirname(this.resourcePath)
  })
  const catalog = configureCatalog(config)

  const locale = catalog.getLocale(this.resourcePath)

  const catalogs = catalog.readAll()
  const messages = R.mapObjIndexed(
    (_, key) =>
      catalog.getTranslation(catalogs, locale, key, {
        fallbackLocale: config.fallbackLocale,
        sourceLocale: config.sourceLocale
      }),
    catalogs[locale]
  )

  // In production we don't want untranslated strings. It's better to use message
  // keys as a last resort.
  // In development, however, we want to catch missing strings with `missing` parameter

@lingui/cli

CLI for working wit message catalogs

MIT
Latest version published 4 days ago

Package Health Score

92 / 100
Full package analysis