Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
.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
})
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]
)
.arguments("")
.option("--config
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: "_" })