Skip to content

Commit a1a49ca

Browse files
committed
Fixed default localizers handling of done callback.
1 parent 3833362 commit a1a49ca

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Node/core/src/DefaultLocalizer.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export class DefaultLocalizer implements ILocalizer {
203203
});
204204
}
205205

206-
public load(locale: string, done: ErrorCallback): void {
206+
public load(locale: string, done?: ErrorCallback): void {
207207
if (locale) {
208208
locale = locale.toLowerCase();
209209
}
@@ -213,7 +213,9 @@ export class DefaultLocalizer implements ILocalizer {
213213

214214
if (DefaultLocalizer.localeRequests[localeRequestKey]) {
215215
logger.debug("localizer::already loaded requested locale: %s", localeRequestKey);
216-
done(null);
216+
if (done) {
217+
done(null);
218+
}
217219
return;
218220
}
219221

@@ -276,12 +278,12 @@ export class DefaultLocalizer implements ILocalizer {
276278

277279
],
278280
(err, results) => {
279-
if (err) {
280-
done(err);
281-
} else {
281+
if (!err) {
282282
DefaultLocalizer.localeRequests[localeRequestKey] = true;
283283
logger.debug("localizer::loaded requested locale: %s", localeRequestKey);
284-
done();
284+
}
285+
if (done) {
286+
done(err);
285287
}
286288
});
287289
}

Node/core/src/interfaces.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ interface ILocationV2 {
164164

165165
interface ILocalizer {
166166
initialize(localizerSettings?: ILocalizerSettings): void;
167-
load(locale: string, callback: ErrorCallback): void;
167+
load(locale: string, callback?: ErrorCallback): void;
168168
defaultLocale(locale?: string): string
169169
gettext(locale: string, msgid: string, namespace?: string): string;
170170
trygettext(locale: string, msgid: string, namespace?: string): string;

0 commit comments

Comments
 (0)