Skip to content

Commit

Permalink
Use the common webpack configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
  • Loading branch information
raimund-schluessler committed Apr 8, 2022
1 parent 71e8f2f commit 8b084ec
Show file tree
Hide file tree
Showing 10 changed files with 5,696 additions and 5,763 deletions.
40 changes: 40 additions & 0 deletions build/translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const fs = require('fs')
const gettextParser = require('gettext-parser')

// https://github.com/alexanderwallin/node-gettext#usage
// https://github.com/alexanderwallin/node-gettext#load-and-add-translations-from-mo-or-po-files
const translations = fs
.readdirSync('./l10n')
.filter(name => name !== 'messages.pot' && name.endsWith('.pot'))
.map(file => {
const path = './l10n/' + file
const locale = file.slice(0, -'.pot'.length)

const po = fs.readFileSync(path)
const json = gettextParser.po.parse(po)

// Compress translations Content
const translations = {}
for (const key in json.translations['']) {
if (key !== '') {
// Plural
if ('msgid_plural'in json.translations[''][key]) {
translations[json.translations[''][key].msgid] = {
pluralId: json.translations[''][key].msgid_plural,
msgstr: json.translations[''][key].msgstr,
}
continue
}

// Singular
translations[json.translations[''][key].msgid] = json.translations[''][key].msgstr[0]
}
}

return {
locale,
translations,
}
})

module.exports = translations
2 changes: 1 addition & 1 deletion cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const getCompareSnapshotsPlugin = require('cypress-visual-regression/dist/plugin
const webpack = require('@cypress/webpack-preprocessor')
const { startDevServer } = require('@cypress/webpack-dev-server')

const webpackOptions = require('../../webpack.dev.js')
const webpackOptions = require('../../webpack.config.js')
webpackOptions.externals = {}

const options = {
Expand Down
Loading

0 comments on commit 8b084ec

Please sign in to comment.