How to use @lingui/cli - 2 common examples

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
github lingui / js-lingui / packages / loader / src / index.js View on Github external
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
  // of I18nProvider (React) or setupI18n (core) and therefore we need to get
  // empty translations if missing.
  const strict = process.env.NODE_ENV !== "production"
  return createCompiledCatalog(
    locale,
    messages,
    strict,
    config.compileNamespace,
    config.pseudoLocale
  )
}

@lingui/cli

CLI for working wit message catalogs

MIT
Latest version published 14 days ago

Package Health Score

92 / 100
Full package analysis