From e07fd8ce6c4bff7fe55e072694d32799eed1811d Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Sun, 31 Jan 2021 12:37:33 +0100 Subject: [PATCH] allow specifying transform options in environment variables --- README.md | 8 ++++---- index.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index df98552..0b466a1 100644 --- a/README.md +++ b/README.md @@ -70,19 +70,19 @@ The following options can be passed to the transform: ##### `locale` -`locale` specifies the locale which you want to return when bundling. It defaults to `en`. +`locale` specifies the locale which you want to return when bundling. It defaults to `en` or `process.env.LOCALE` when set. ##### `defaultLocale` -`defaultLocale` specifies the default locale that is used to define strings in code. It defaults to `en`. +`defaultLocale` specifies the default locale that is used to define strings in code. It defaults to `en` or `process.env.DEFAULT_LOCALE` when set. ##### `source` -`source` specifies the directory in which the `.po` files are stored. It defaults to `./locales` +`source` specifies the directory in which the `.po` files are stored. It defaults to `./locales` or `process.env.SOURCE` when set. ##### `global` -`global` defines the global function identifier that is used for defining strings in code. It defaults to `__`. +`global` defines the global function identifier that is used for defining strings in code. It defaults to `__` or `process.env.GLOBAL` when set. ## License diff --git a/index.js b/index.js index 0331b24..9b69cbc 100644 --- a/index.js +++ b/index.js @@ -11,10 +11,10 @@ var PO = require('pofile') module.exports = transform function transform (file, options) { - var locale = options.locale || 'en' - var defaultLocale = options.defaultLocale || 'en' - var globalFunctionIdentifier = options.global || '__' - var source = options.source || './locales/' + var locale = options.locale || process.env.LOCALE || 'en' + var defaultLocale = options.defaultLocale || process.env.DEFAULT_LOCALE || 'en' + var globalFunctionIdentifier = options.global || process.env.GLOBAL || '__' + var source = options.source || process.env.SOURCE || './locales/' var buf = '' return through(function (chunk, enc, next) {