11const webpackConfig = require ( '@nextcloud/webpack-vue-config' )
22const webpackRules = require ( '@nextcloud/webpack-vue-config/rules' )
33
4- const fs = require ( 'fs' )
5- const gettextParser = require ( 'gettext-parser' )
64const glob = require ( 'glob' )
75const md5 = require ( 'md5' )
86const path = require ( 'path' )
7+ const translations = require ( './translations' )
98
109const { DefinePlugin } = require ( 'webpack' )
1110const nodeExternals = require ( 'webpack-node-externals' )
@@ -18,42 +17,6 @@ const SCOPE_VERSION = JSON.stringify(versionHash)
1817
1918console . info ( 'This build version hash is' , versionHash , '\n' )
2019
21- // https://github.com/alexanderwallin/node-gettext#usage
22- // https://github.com/alexanderwallin/node-gettext#load-and-add-translations-from-mo-or-po-files
23- const translations = fs
24- . readdirSync ( './l10n' )
25- . filter ( name => name !== 'messages.pot' && name . endsWith ( '.pot' ) )
26- . map ( file => {
27- const path = './l10n/' + file
28- const locale = file . substr ( 0 , file . length - '.pot' . length )
29-
30- const po = fs . readFileSync ( path )
31- const json = gettextParser . po . parse ( po )
32-
33- // Compress translations Content
34- const translations = { }
35- for ( const key in json . translations [ '' ] ) {
36- if ( key !== '' ) {
37- // Plural
38- if ( 'msgid_plural' in json . translations [ '' ] [ key ] ) {
39- translations [ json . translations [ '' ] [ key ] . msgid ] = {
40- pluralId : json . translations [ '' ] [ key ] . msgid_plural ,
41- msgstr : json . translations [ '' ] [ key ] . msgstr ,
42- }
43- continue
44- }
45-
46- // Singular
47- translations [ json . translations [ '' ] [ key ] . msgid ] = json . translations [ '' ] [ key ] . msgstr [ 0 ]
48- }
49- }
50-
51- return {
52- locale,
53- translations,
54- }
55- } )
56-
5720webpackConfig . entry = {
5821 ncvuecomponents : path . join ( __dirname , 'src' , 'index.js' ) ,
5922 ...glob . sync ( 'src/components/*/index.js' ) . reduce ( ( acc , item ) => {
0 commit comments