Skip to content

Commit

Permalink
lingui#587: Optional line numbers for lingui format
Browse files Browse the repository at this point in the history
  • Loading branch information
MarttiR committed Nov 14, 2019
1 parent c684206 commit b4c1c15
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
5 changes: 4 additions & 1 deletion packages/cli/src/api/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export default (config: LinguiConfig): CatalogApi => {
)

const created = !fs.existsSync(filename)
format.write(filename, messages, { language: locale })
format.write(filename, messages, {
language: locale,
...config.formatOptions
})
return [created, filename]
},

Expand Down
11 changes: 9 additions & 2 deletions packages/cli/src/api/formats/lingui.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
// @flow
import fs from "fs"
import * as R from "ramda"

import type { TranslationsFormat } from "../types"

const removeOrigins = R.map(({ origin, ...message }) => message)

const format: TranslationsFormat = {
filename: "messages.json",

write(filename, catalog) {
fs.writeFileSync(filename, JSON.stringify(catalog, null, 2))
write(filename, catalog, options = {}) {
let outputCatalog = catalog
if (options.origins === false) {
outputCatalog = removeOrigins(catalog)
}
fs.writeFileSync(filename, JSON.stringify(outputCatalog, null, 2))
},

read(filename) {
Expand Down
3 changes: 3 additions & 0 deletions packages/conf/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export const defaultConfig = {
srcPathIgnorePatterns: [NODE_MODULES],
sorting: "messageId",
format: "lingui",
formatOptions: {
origins: true
},
rootDir: ".",
extractBabelOptions: {
plugins: [],
Expand Down
4 changes: 2 additions & 2 deletions scripts/build/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"bundleSizes": {
"@lingui/core.development.js (NODE_DEV)": {
"size": 14825,
"gzip": 3861
"gzip": 3860
},
"@lingui/core.production.min.js (NODE_PROD)": {
"size": 4286,
Expand All @@ -18,7 +18,7 @@
},
"dev.development.js (NODE_DEV)": {
"size": 14825,
"gzip": 3861
"gzip": 3860
},
"dev.production.min.js (NODE_PROD)": {
"size": 4286,
Expand Down

0 comments on commit b4c1c15

Please sign in to comment.