Skip to content

Commit 4d30861

Browse files
committed
Updated passing of the localizerSettings info to the default localizer.
1 parent a1a49ca commit 4d30861

File tree

5 files changed

+11
-18
lines changed

5 files changed

+11
-18
lines changed

Node/core/src/DefaultLocalizer.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ export class DefaultLocalizer implements ILocalizer {
4444
private static filesParsedMap: any = {};
4545
private static map: any = {};
4646

47-
constructor() {
48-
}
49-
50-
initialize(settings: ILocalizerSettings = {}) {
47+
constructor(settings: IDefaultLocalizerSettings = {}) {
5148
if (settings.botLocalePath) {
5249
this.botLocalePath = settings.botLocalePath.toLowerCase();
5350
if (this.botLocalePath.charAt(this.botLocalePath.length - 1) != '/') {

Node/core/src/Session.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export interface ISessionOptions {
5151
dialogId: string;
5252
dialogArgs?: any;
5353
localizer?: ILocalizer;
54-
localizerSettings?: ILocalizerSettings;
54+
localizerSettings?: IDefaultLocalizerSettings;
5555
autoBatchDelay?: number;
5656
dialogErrorMessage?: string|string[]|IMessage|IIsMessage;
5757
actions?: actions.ActionSet;
@@ -77,11 +77,10 @@ export class Session extends events.EventEmitter implements ISession {
7777
this.library = options.library;
7878

7979
if (!options.localizer) {
80-
this.localizer = new dfLoc.DefaultLocalizer();
80+
this.localizer = new dfLoc.DefaultLocalizer(options.localizerSettings);
8181
} else {
8282
this.localizer = options.localizer;
8383
}
84-
this.localizer.initialize(options.localizerSettings);
8584

8685
if (typeof this.options.autoBatchDelay !== 'number') {
8786
this.options.autoBatchDelay = 250; // 250ms delay

Node/core/src/botbuilder.d.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ export interface IIsFact {
310310
toFact(): IFact;
311311
}
312312

313-
interface ILocalizerSettings {
313+
/** Settings used to initialize an ILocalizer implementation. */
314+
interface IDefaultLocalizerSettings {
314315
/** The path to the parent of the bot's locale directory */
315316
botLocalePath?: string;
316317

@@ -320,12 +321,6 @@ interface ILocalizerSettings {
320321

321322
/** Plugin for localizing messages sent to the user by a bot. */
322323
export interface ILocalizer {
323-
/**
324-
* Intitializes the localizer.
325-
* @param localizerSettings (Optional) settings to supply to the localizer.
326-
*/
327-
initialize(localizerSettings?: ILocalizerSettings): void;
328-
329324
/**
330325
* Loads the localied table for the supplied locale, and call's the supplied callback once the load is complete.
331326
* @param locale The locale to load.
@@ -741,9 +736,12 @@ export interface IUniversalBotSettings {
741736
/** (Optional) arguments to pass to the initial dialog for a conversation. */
742737
defaultDialogArgs?: any;
743738

744-
/** (Optional) localizer used to localize the bots responses to the user. */
739+
/** (Optional) cutstom localizer used to localize the bots responses to the user. */
745740
localizer?: ILocalizer;
746741

742+
/** (Optional) settings used to configure the frameworks built in default localizer. */
743+
localizerSettings?: IDefaultLocalizerSettings;
744+
747745
/** (Optional) function used to map the user ID for an incoming message to another user ID. This can be used to implement user account linking. */
748746
lookupUser?: (address: IAddress, done: (err: Error, user: IIdentity) => void) => void;
749747

Node/core/src/bots/UniversalBot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface IUniversalBotSettings {
4848
defaultDialogId?: string;
4949
defaultDialogArgs?: any;
5050
localizer?: ILocalizer;
51-
localizerSettings?: ILocalizerSettings;
51+
localizerSettings?: IDefaultLocalizerSettings;
5252
lookupUser?: ILookupUser;
5353
processLimit?: number;
5454
autoBatchDelay?: number;

Node/core/src/interfaces.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,14 @@ interface ILocationV2 {
163163
}
164164

165165
interface ILocalizer {
166-
initialize(localizerSettings?: ILocalizerSettings): void;
167166
load(locale: string, callback?: ErrorCallback): void;
168167
defaultLocale(locale?: string): string
169168
gettext(locale: string, msgid: string, namespace?: string): string;
170169
trygettext(locale: string, msgid: string, namespace?: string): string;
171170
ngettext(locale: string, msgid: string, msgid_plural: string, count: number, namespace?: string): string;
172171
}
173172

174-
interface ILocalizerSettings {
173+
interface IDefaultLocalizerSettings {
175174
botLocalePath?: string;
176175
defaultLocale?: string;
177176
}

0 commit comments

Comments
 (0)