How to use @lingui/conf - 5 common examples

To help you get started, we’ve selected a few @lingui/conf 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 / cli / src / lingui-compile.js View on Github external
)
    .on("--help", function() {
      console.log("\n  Examples:\n")
      console.log(
        "    # Compile translations and use defaults or message IDs for missing translations"
      )
      console.log(`    $ ${helpRun("compile")}`)
      console.log("")
      console.log("    # Compile translations but fail when there're missing")
      console.log("    # translations (don't replace missing translations with")
      console.log("    # default messages or message IDs)")
      console.log(`    $ ${helpRun("compile --strict")}`)
    })
    .parse(process.argv)

  const config = getConfig({ configPath: program.config })

  if (program.format) {
    const msg =
      "--format option is deprecated and will be removed in @lingui/cli@3.0.0." +
      " Please set format in configuration https://lingui.js.org/ref/conf.html#format"
    console.warn(msg)
    config.format = program.format
  }

  const results = command(config, {
    verbose: program.verbose || false,
    allowEmpty: !program.strict,
    typescript: program.typescript || false,
    namespace: program.namespace // we want this to be undefined if user does not specify so default can be used
  })
github lingui / js-lingui / packages / loader / src / index.js View on Github external
export default function(source) {
  const options = loaderUtils.getOptions(this) || {}

  // 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]
  )
github lingui / js-lingui / packages / babel-plugin-extract-messages / src / index.js View on Github external
export default function({ types: t }) {
  let localTransComponentName

  const opts = getConfig()
  const optsBaseDir = opts.rootDir

  function isTransComponent(node) {
    return (
      t.isJSXElement(node) &&
      t.isJSXIdentifier(node.openingElement.name, {
        name: localTransComponentName
      })
    )
  }

  const isNoopMethod = node => t.isIdentifier(node, { name: "i18nMark" })
  const isI18nMethod = node =>
    t.isMemberExpression(node) &&
    t.isIdentifier(node.object, { name: "i18n" }) &&
    t.isIdentifier(node.property, { name: "_" })

@lingui/conf

Get lingui configuration from package.json

MIT
Latest version published 6 days ago

Package Health Score

95 / 100
Full package analysis

Popular @lingui/conf functions