How to use the i18n.gettext function in i18n

To help you get started, we’ve selected a few i18n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hinojosachapel / CorePlus / src / dialogs / welcome / index.js View on Github external
getWelcomeCard(locale) {
        welcomeCard.body[0].url = process.env.publicResourcesUrl + '/public/welcome_logo.png';
        welcomeCard.body[1].text = localizer.gettext(locale, 'welcome.tittle');

        // Restart command should be localized.
        const restartCommand = localizer.gettext(locale, 'restartCommand');
        welcomeCard.body[2].text = localizer.gettext(locale, 'welcome.subtittle', restartCommand);

        welcomeCard.actions[0].title = localizer.gettext(locale, 'welcome.privacy');
        const language = locale.substring(0, 2);
        welcomeCard.actions[0].url = process.env.publicResourcesUrl + '/public/privacy_policy_' + language + '.pdf';

        const card = CardFactory.adaptiveCard(welcomeCard);
        return { attachments: [card] };
    }
}
github hinojosachapel / CorePlus / javascript_nodejs / src / dialogs / greeting / index.js View on Github external
async greetUser(step) {
        const userData = await this.userDataAccessor.get(step.context);
        const locale = userData.locale;

        // Display to the user their profile information and end dialog
        // Here we use {{Mustache}} patterns: https://github.com/mashpie/i18n-node/blob/master/i18n.js#L543
        let greet = localizer.gettext(locale, 'greeting.greetUser1', { "userName": userData.name || '', "userCity": userData.city || '' });
        await step.context.sendActivity(greet);
        await step.context.sendActivity(localizer.gettext(locale, 'greeting.greetUser2'));

        return await step.endDialog();
    }
github hinojosachapel / CorePlus / javascript_nodejs / src / dialogs / greeting / index.js View on Github external
async validateName(validatorContext) {
        const userData = await this.userDataAccessor.get(validatorContext.context);
        const locale = userData.locale;

        // Validate that the user entered a minimum length for their name
        const value = (validatorContext.recognized.value || '').trim();

        if (value.length >= NAME_LENGTH_MIN) {
            return VALIDATION_SUCCEEDED;
        } else {
            await validatorContext.context.sendActivity(localizer.gettext(locale, 'greeting.validateName', NAME_LENGTH_MIN));
            return VALIDATION_FAILED;
        }
    }
github hinojosachapel / CorePlus / src / dialogs / main / index.js View on Github external
async routeMessage(dc, locale) {
        let turnResult = DIALOG_TURN_STATUS_DEFAULT;
        const utterance = (dc.context.activity.text || '').trim().toLowerCase();

        // Handle commands
        if (utterance === localizer.gettext(locale, 'restartCommand')) {
            let userData = new UserData();
            // Save locale and any other data you need to persist between resets
            userData.locale = locale;
            await this.userDataAccessor.set(dc.context, userData);
            await dc.cancelAllDialogs();
            turnResult = await dc.beginDialog(WelcomeDialog.name);
        } else if (dc.activeDialog && dc.activeDialog.id === QnADialog.name) {
            // If current active dialog is QnADialog, continue the flow inside that dialog.
            turnResult = await dc.continueDialog();
        } else {
            // Perform a call to LUIS to retrieve results for the current activity message.
            const results = await this.luisRecognizers[locale].recognize(dc.context);
            const topIntent = LuisRecognizer.topIntent(results, undefined, LUIS_CONFIDENCE_THRESHOLD);

            // Based on LUIS topIntent, evaluate if we have an interruption.
            const interrupted = await this.chitchatDialog.isTurnInterrupted(dc, topIntent);
github hinojosachapel / CorePlus / javascript_nodejs / src / dialogs / greeting / index.js View on Github external
async validateCity(validatorContext) {
        const userData = await this.userDataAccessor.get(validatorContext.context);
        const locale = userData.locale;

        // Validate that the user entered a minimum length for their name
        const value = (validatorContext.recognized.value || '').trim();

        if (value.length >= CITY_LENGTH_MIN) {
            return VALIDATION_SUCCEEDED;
        } else {
            await validatorContext.context.sendActivity(localizer.gettext(locale, 'greeting.validateCity', CITY_LENGTH_MIN));
            return VALIDATION_FAILED;
        }
    }
github BlythMeister / Fitbit-Overview-Face / src / app / date.js View on Github external
export function drawDate(now) {
  let date = getDateInFormat(now);
  let dayName = gettext(`day-${now.getDay()}`);

  dayEl.text = `${dayName}`;
  dateEl.text =  `${date}`;
}
github BlythMeister / Fitbit-Overview-Face / src / app / date.js View on Github external
export function getDateInFormat(now){
  let day = now.getDate();
  let monthName = gettext(`month-long-${now.getMonth()}`);
  let monthAbrv = gettext(`month-short-${now.getMonth()}`);
  let monthIndex = now.getMonth() + 1;
  let year = now.getYear() % 100;  

  switch(dateFormat) {
    case "dd.mm.yy":
      return zeroPad(day) + "." + zeroPad(monthIndex) + "." + year;
    case "dd/mm/yy":
      return zeroPad(day) + "/" + zeroPad(monthIndex) + "/" + year;
    case "dd mmm yy":
      return zeroPad(day) + " " + monthAbrv + " " + year;
    case "dd mmmm yy":
      return zeroPad(day) + " " + monthName + " " + year;
    case "mm.dd.yy":
      return zeroPad(monthIndex) + "." + zeroPad(day) + "." + year;
    case "mmm dd yy":
      return monthAbrv + " " + zeroPad(day) + " " + year;
github hinojosachapel / CorePlus / src / dialogs / qna / index.js View on Github external
async promptFeedbackStep(step) {
        const userData = await this.userDataAccessor.get(step.context);
        const locale = userData.locale;

        const prompt = localizer.gettext(locale, 'qna.requestFeedback');
        const choiceYes = Utils.getChoiceYes(locale, 'qna.helpful');
        const choiceNo = Utils.getChoiceNo(locale, 'qna.notHepful');

        return await step.prompt(ASK_FEEDBACK_PROMPT, prompt, [choiceYes, choiceNo]);
    }
github hinojosachapel / CorePlus / javascript_nodejs / src / dialogs / shared / utils.js View on Github external
static async showMainMenu(context, locale) {
        const hints = localizer.gettext(locale, 'hints');
        const buttons = [];

        Object.values(hints).forEach(value => {
            buttons.push(value);
        });

        await context.sendActivity(this.getHeroCard(buttons));
    }