Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Italian Support for Confirm/Choice Prompts #1500

Merged
merged 11 commits into from
Feb 22, 2020
11 changes: 11 additions & 0 deletions libraries/botbuilder-dialogs/src/prompts/promptCultureModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface PromptCultureModel {
* Class container for currently-supported Culture Models in Confirm and Choice Prompt.
*/
export class PromptCultureModels {

public static Chinese: PromptCultureModel = {
locale: Culture.Chinese,
separator: ', ',
Expand Down Expand Up @@ -88,6 +89,15 @@ export class PromptCultureModels {
noInLanguage: 'Nein',
}

public static Italian: PromptCultureModel = {
locale: Culture.Italian,
separator: ', ',
inlineOr: ' o ',
inlineOrMore: ' o ',
yesInLanguage: 'Si',
noInLanguage: 'No',
}

public static Japanese: PromptCultureModel = {
locale: Culture.Japanese,
separator: '、 ',
Expand Down Expand Up @@ -152,6 +162,7 @@ export class PromptCultureModels {
PromptCultureModels.English,
PromptCultureModels.French,
PromptCultureModels.German,
PromptCultureModels.Italian,
PromptCultureModels.Japanese,
PromptCultureModels.Portuguese,
PromptCultureModels.Spanish,
Expand Down
1 change: 1 addition & 0 deletions libraries/botbuilder-dialogs/tests/choicePrompt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ describe('ChoicePrompt', function () {
'en-us',
'fr-fr',
'de-de',
'it-it',
'ja-jp',
'pt-br',
'zh-cn'
Expand Down
5 changes: 3 additions & 2 deletions libraries/botbuilder-dialogs/tests/confirmPrompt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ describe('ConfirmPrompt', function () {
'fr-fr',
'de-de',
'ja-jp',
'it-it',
'pt-br',
'zh-cn'
];
Expand Down Expand Up @@ -556,7 +557,7 @@ describe('ConfirmPrompt', function () {
.assertReply(`The result found is 'true'.`);
});

it('should recogize valid number and default to en if locale invalid string.', async function () {
it('should recognize valid number and default to en if locale invalid string.', async function () {
const adapter = new TestAdapter(async (turnContext) => {

turnContext.activity.locale = 'invalid-locale';
Expand Down Expand Up @@ -591,7 +592,7 @@ describe('ConfirmPrompt', function () {
.assertReply(`The result found is 'true'.`);
});

it('should recogize valid number and default to en if defaultLocale invalid string.', async function () {
it('should recognize valid number and default to en if defaultLocale invalid string.', async function () {
const adapter = new TestAdapter(async (turnContext) => {

const dc = await dialogs.createContext(turnContext);
Expand Down
73 changes: 73 additions & 0 deletions libraries/botbuilder-dialogs/tests/promptCultureModels.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const assert = require('assert');
const { PromptCultureModels } = require('../lib')

describe('Prompt Culture Models Tests', function() {
this.timeout(5000);

it('should correctly map to nearest language', function() {
const locales = [
'es-es',
'nl-nl',
'en-us',
'fr-fr',
'de-de',
'ja-jp',
'it-it',
'pt-br',
'zh-cn'
];
// es-ES
const capEnding = (locale) => {
return `${ locale.split('-')[0] }-${ locale.split('-')[1].toUpperCase() }`;
};
// es-Es
const titleEnding = (locale) => {
locale[3] = locale.charAt(3).toUpperCase();
return locale;
};
// ES
const capTwoLetter = (locale) => {
return locale.split('-')[0].toUpperCase();
};
// es
const lowerTwoLetter = (locale) => {
return locale.split('-')[0].toLowerCase();
};

// This creates an object of the correct locale along with its test locales
const localeTests = locales.reduce((obj, locale) => {
obj[locale] = [
locale,
capEnding(locale),
titleEnding(locale),
capTwoLetter(locale),
lowerTwoLetter(locale)
];
return obj;
}, {});

Object.keys(localeTests).map((validLocale) => {
localeTests[validLocale].map((testLocale) => {
assert.strictEqual(PromptCultureModels.mapToNearestLanguage(testLocale), validLocale);
});
});
});

it('should return all supported cultures', function() {
const expected = [
PromptCultureModels.Chinese,
PromptCultureModels.Dutch,
PromptCultureModels.English,
PromptCultureModels.French,
PromptCultureModels.German,
PromptCultureModels.Italian,
PromptCultureModels.Japanese,
PromptCultureModels.Portuguese,
PromptCultureModels.Spanish
];

const supportedCultures = PromptCultureModels.getSupportedCultures();

assert.deepEqual(supportedCultures, expected);
});
});