-
Notifications
You must be signed in to change notification settings - Fork 4
/
vite.config.ts
37 lines (33 loc) · 985 Bytes
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { createLibConfig } from '@nextcloud/vite-config'
import { readFileSync, readdirSync } from 'node:fs'
import { po as poParser } from 'gettext-parser'
const translations = Object.fromEntries(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 = readFileSync(path)
const json = poParser.parse(po)
// compress by removing unneeded information
delete json.headers
delete json.translations['']['']
Object.keys(json.translations['']).forEach((key) => {
delete json.translations[''][key].comments
})
return [
locale,
json
]
}))
export default createLibConfig({
index: 'lib/index.ts',
}, {
libraryFormats: ['es', 'cjs'],
replace: {
LOCALES: JSON.stringify(translations)
},
})