Skip to content

Commit 83f4a1b

Browse files
committed
enh: Move package to vite for bundling + compress translations
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 4994d9f commit 83f4a1b

15 files changed

Lines changed: 6608 additions & 17491 deletions

babel.config.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

build/extract-l10n.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { GettextExtractor, JsExtractors } = require('gettext-extractor')
1+
import { GettextExtractor, JsExtractors } from 'gettext-extractor'
22

3-
const extractor = new GettextExtractor()
3+
const extractor = new GettextExtractor();
44

55
extractor
66
.createJsParser([
@@ -11,7 +11,7 @@ extractor
1111
},
1212
}),
1313
])
14-
.parseFilesGlob('./lib/**/*.@(ts|js)')
14+
.parseFilesGlob('./lib/**/*.@(ts|js)');
1515

1616
extractor.savePotFile('./l10n/messages.pot')
1717

l10n/messages.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ msgid ""
22
msgstr ""
33
"Content-Type: text/plain; charset=UTF-8\n"
44

5-
#: lib/index.ts:22
5+
#: lib/index.ts:20
66
msgid "seconds"
77
msgstr ""

lib/index.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
import moment from 'moment'
1+
import moment from 'moment/min/moment-with-locales'
22
import Gettext from 'node-gettext'
33
import { getLocale } from '@nextcloud/l10n'
44

5-
const gt = new Gettext()
6-
75
const locale = getLocale()
8-
LOCALES.forEach((data) => {
9-
gt.addTranslations(data.locale, 'messages', data.json)
10-
})
11-
gt.setLocale(locale)
12-
// eslint-disable-next-line import/no-named-as-default-member
6+
const translations = LOCALES
7+
138
moment.locale(locale)
149

1510
// Only update the locale of moment.js if it's available. Moment.js ships more locales than we
1611
// track in transifex, so we prefer the included translation. Always prefer our default english
1712
// translation.
18-
if (locale === 'en' || LOCALES.find(data => data.locale === locale)) {
19-
// eslint-disable-next-line import/no-named-as-default-member
13+
if (locale === 'en' || locale in translations) {
14+
const gt = new Gettext()
15+
gt.addTranslations(locale, 'messages', translations[locale])
16+
gt.setLocale(locale)
17+
2018
moment.updateLocale(moment.locale(), {
2119
relativeTime: {
2220
s: gt.gettext('seconds'),

0 commit comments

Comments
 (0)