blob: 0416e8b1ce4dfbf6c6f9aaf9f38554dd983a3bb6 (
plain)
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
|
import Gettext from 'node-gettext';
import { LocalizationContexts } from './localization-contexts';
import log from './logging';
const SOURCE_LANGUAGE = 'en';
function setErrorHandler(catalogue: Gettext) {
catalogue.on('error', (error) => {
log.warn(`Gettext error: ${error}`);
});
}
const gettextOptions = { sourceLocale: SOURCE_LANGUAGE };
declare class GettextWithAppContexts extends Gettext {
pgettext(msgctxt: LocalizationContexts, msgid: string): string;
npgettext(
msgctxt: LocalizationContexts,
msgid: string,
msgidPlural: string,
count: number,
): string;
}
export const messages = new Gettext(gettextOptions) as GettextWithAppContexts;
messages.setTextDomain('messages');
setErrorHandler(messages);
export const relayLocations = new Gettext(gettextOptions);
relayLocations.setTextDomain('relay-locations');
setErrorHandler(relayLocations);
|