-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the common webpack configuration
Signed-off-by: Raimund Schlüßler <[email protected]>
- Loading branch information
1 parent
71e8f2f
commit 8b084ec
Showing
10 changed files
with
5,696 additions
and
5,763 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.