Skip to content

Commit

Permalink
fix(lint): Fix linter errors
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Jan 9, 2024
1 parent f52c4c2 commit 72a5dfa
Show file tree
Hide file tree
Showing 7 changed files with 16,590 additions and 6,460 deletions.
26 changes: 13 additions & 13 deletions build/extract-l10n.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const { GettextExtractor, JsExtractors } = require('gettext-extractor');
const { GettextExtractor, JsExtractors } = require('gettext-extractor')

let extractor = new GettextExtractor();
const extractor = new GettextExtractor()

extractor
.createJsParser([
JsExtractors.callExpression('gt.gettext', {
arguments: {
text: 0,
context: 1
}
}),
])
.parseFilesGlob('./lib/**/*.@(ts|js)');
.createJsParser([
JsExtractors.callExpression('gt.gettext', {
arguments: {
text: 0,
context: 1,
},
}),
])
.parseFilesGlob('./lib/**/*.@(ts|js)')

extractor.savePotFile('./l10n/messages.pot');
extractor.savePotFile('./l10n/messages.pot')

extractor.printStats();
extractor.printStats()
2 changes: 1 addition & 1 deletion l10n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"

#: lib/index.ts:20
#: lib/index.ts:22
msgid "seconds"
msgstr ""
6 changes: 3 additions & 3 deletions lib/constants.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
interface Translations {
locale: string
json: object
locale: string
json: object
}

declare const LOCALES: Translations[];
declare const LOCALES: Translations[]
16 changes: 9 additions & 7 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ import { getLocale } from '@nextcloud/l10n'
const gt = new Gettext()

const locale = getLocale()
LOCALES.map(data => {
gt.addTranslations(data.locale, 'messages', data.json)
LOCALES.forEach((data) => {
gt.addTranslations(data.locale, 'messages', data.json)
})
gt.setLocale(locale)
// eslint-disable-next-line import/no-named-as-default-member
moment.locale(locale)

// Only update the locale of moment.js if it's available. Moment.js ships more locales than we
// track in transifex, so we prefer the included translation. Always prefer our default english
// translation.
if (locale === 'en' || LOCALES.find(data => data.locale === locale)) {
moment.updateLocale(moment.locale(), {
relativeTime: {
s: gt.gettext('seconds'),
},
})
// eslint-disable-next-line import/no-named-as-default-member
moment.updateLocale(moment.locale(), {
relativeTime: {
s: gt.gettext('seconds'),
},
})
}

export default moment
Loading

0 comments on commit 72a5dfa

Please sign in to comment.