Skip to content

Commit

Permalink
allow specifying transform options in environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
m90 committed Jan 31, 2021
1 parent d281b9b commit e07fd8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<LOCALE>.po` files are stored. It defaults to `./locales`
`source` specifies the directory in which the `<LOCALE>.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

Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e07fd8c

Please sign in to comment.