Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions libraries/botbuilder-dialogs/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
NOTICES AND INFORMATION
Do Not Translate or Localize

This software incorporates material from third parties. Microsoft makes certain
open source code available at https://3rdpartysource.microsoft.com, or you may
send a check or money order for US $5.00, including the product name, the open
source component name, and version number, to:

Source Code Compliance Team
Microsoft Corporation
One Microsoft Way
Redmond, WA 98052
USA

Notwithstanding any other terms, you may reverse engineer this software to the
extent required to debug changes to any libraries licensed under the GNU Lesser
General Public License.

Component: cldr-data

Open Source License/Copyright Notice:

UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE

Unicode Data Files include all data files under the directories
http://www.unicode.org/Public/, http://www.unicode.org/reports/, and
http://www.unicode.org/cldr/data/. Unicode Data Files do not include PDF
online code charts under the directory http://www.unicode.org/Public/.
Software includes any source code published in the Unicode Standard or under
the directories http://www.unicode.org/Public/,
http://www.unicode.org/reports/, and http://www.unicode.org/cldr/data/.

NOTICE TO USER: Carefully read the following legal agreement. BY
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S DATA FILES
("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), YOU UNEQUIVOCALLY ACCEPT, AND
AGREE TO BE BOUND BY, ALL OF THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF
YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA
FILES OR SOFTWARE.

COPYRIGHT AND PERMISSION NOTICE

Copyright © 1991-2015 Unicode, Inc. All rights reserved. Distributed under
the Terms of Use in http://www.unicode.org/copyright.html.

Permission is hereby granted, free of charge, to any person obtaining a
copy of the Unicode data files and any associated documentation (the "Data
Files") or Unicode software and any associated documentation (the "Software")
to deal in the Data Files or Software without restriction, including without
limitation the rights to use, copy, modify, merge, publish, distribute, and/or
sell copies of the Data Files or Software, and to permit persons to whom the
Data Files or Software are furnished to do so, provided that (a) the above
copyright notice(s) and this permission notice appear with all copies of the
Data Files or Software, (b) both the above copyright notice(s) and this
permission notice appear in associated documentation, and (c) there is clear
notice in each modified Data File or in the Software as well as in the
documentation associated with the Data File(s) or Software that the data or
software has been modified.

THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD
PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE
DATA FILES OR SOFTWARE.

Except as contained in this notice, the name of a copyright holder shall
not be used in advertising or otherwise to promote the sale, use or other
dealings in these Data Files or Software without prior written authorization
of the copyright holder.
1 change: 0 additions & 1 deletion libraries/botbuilder-dialogs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"@microsoft/recognizers-text-suite": "1.1.4",
"@types/node": "^10.12.18",
"botbuilder-core": "4.1.6",
"cldr-data": "^35.1.0",
"globalize": "^1.4.2"
},
"devDependencies": {
Expand Down
210 changes: 210 additions & 0 deletions libraries/botbuilder-dialogs/scripts/gen-cldr-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
/*
import * as Chinese from 'cldr-data/main/zh/numbers.json';
import * as English from 'cldr-data/main/en/numbers.json';
import * as Dutch from 'cldr-data/main/nl/numbers.json';
import * as German from 'cldr-data/main/de/numbers.json';
import * as Japanese from 'cldr-data/main/ja/numbers.json';
import * as LikelySubtags from 'cldr-data/supplemental/likelySubtags.json';
import * as NumberingSystem from 'cldr-data/supplemental/numberingSystems.json';
import * as Portuguese from 'cldr-data/main/pt/numbers.json';
import * as Spanish from 'cldr-data/main/es/numbers.json';
*/

// Ensure using node 12 because of recursive mkdir
if (
!process.env.GEN_CLDR_DATA_IGNORE_NODE_VERSION &&
process.version.split('.')[0] < 'v12'
) {
console.error(`
Your node version appears to be below v12: ${ process.version }.
This script will not run correctly on earlier versions of node.
Set 'GEN_CLDR_DATA_IGNORE_NODE_VERSION' environment variable to truthy to override`);
}

const fs = require('fs');
const path = require('path');
const cp = require('child_process');
const os = require('os');

const tempDirectoryName = '.temp-gen-cldr-data';
const tempProjectName = 'temp';
const tempDirectory = path.join(os.tmpdir(), tempDirectoryName, tempProjectName);
const cldrDataDirectory = path.join(tempDirectory, './node_modules/cldr-data');
const vendorDirectory = path.join(__dirname, '../vendor/cldr-data');
const cldrDataPackageName = 'cldr-data';
const cldrDataPackageVersion = '35.1.0';

const numbersDirectoryPaths = [
'main/zh',
'main/en',
'main/nl',
'main/de',
'main/ja',
'main/pt',
'main/es'
];
const supplementalDirectoryName = 'supplemental';

const numbersFileName = 'numbers.json';
const likelySubtagsFileName = 'likelySubtags.json';
const numberingSystemsFileName = 'numberingSystems.json';

async function main() {
const plog = prettyLogger('main');
try {
plog('Making temporary directory: ' + tempDirectory);
createIfNotExistSync(tempDirectory);
} catch (err) {
plog('Could not create temp directory');
plog(err);
plog('Cancelling...');
process.exit(1);
}

try {
plog(
'Creating temp project to install cldr-data into'
);
await exec(
(process.platform === 'win32' ? 'npm.cmd' : 'npm'), ['init', '-y'],
{ cwd: tempDirectory, env: process.env }
);
plog(
'Installing cldr-data into temporary directory (This takes a very long time...)'
);
await exec(
(process.platform === 'win32' ? 'npm.cmd' : 'npm'), ['i', `${ cldrDataPackageName }@${ cldrDataPackageVersion }`, '--no-save'],
{ cwd: tempDirectory, env: process.env }
);
} catch (err) {
plog('Could not install cldr-data');
plog(err);
plog('Cancelling...');
process.exit(1);
}

try {
plog('Creating vendor directories');
numbersDirectoryPaths.forEach(v => {
createIfNotExistSync(path.join(vendorDirectory, v));
});
createIfNotExistSync(
path.join(vendorDirectory, supplementalDirectoryName)
);
} catch (err) {
plog('Could not create vendor directories');
plog(err);
plog('Cancelling...');
process.exit(1);
}

try {
plog(
'Copying files from temporary cldr-data to vendor cldr-data'
);
numbersDirectoryPaths.forEach(v => {
fs.copyFileSync(
path.join(cldrDataDirectory, v, numbersFileName),
path.join(vendorDirectory, v, numbersFileName)
);
});

fs.copyFileSync(
path.join(
cldrDataDirectory,
supplementalDirectoryName,
likelySubtagsFileName
),
path.join(
vendorDirectory,
supplementalDirectoryName,
likelySubtagsFileName
)
);
fs.copyFileSync(
path.join(
cldrDataDirectory,
supplementalDirectoryName,
numberingSystemsFileName
),
path.join(
vendorDirectory,
supplementalDirectoryName,
numberingSystemsFileName
)
);
} catch (err) {
plog('Could not copy files');
plog(err);
plog('Cancelling...');
process.exit(1);
}

try {
plog('Cleaning up temp directory');
fs.rmdirSync(tempDirectory, {
recursive: true
});
} catch (err) {
plog('Could not clean up temp directory: ' + tempDirectory);
plog(err);
plog('Cancelling...');
process.exit(1);
}
}

function createIfNotExistSync(path) {
try {
fs.mkdirSync(path, { recursive: true });
} catch (e) {
if (!e.code === 'EEXIST') {
throw e;
}
}
}

async function exec(command, args, opts) {
const stdout = prettyLogger(command, 'stdout');
const stderr = prettyLogger(command, 'stderr');
const error = prettyLogger(command, 'error');

return new Promise((resolve, reject) => {
const p = cp.spawn(command, args, opts);

p.stdout.on('data', data => {
stdout(`[${ command }][stdout]: ${ data }`);
});

p.stderr.on('data', data => {
stderr(`[${ command }][stderr]: ${ data }`);
});

p.on('error', err => {
error(err);
});

p.on('close', code => {
if(code !== 0) {
return reject(new Error(`"${ command } ${ args.join(' ') }" returned unsuccessful error code: ${ code }`));
} else {
resolve();
}
});
});
}

function prettyLogger(...labels) {
const header = `[${ labels.join('][') }]: `;
return (content) => {
const lines = content.split('\n');
lines.forEach((v)=>console.log(header + v));
};
}

main().catch(err => {
console.error(err);
process.exit(1);
}).then(() => {
console.log('Complete');
process.exit(0);
});
18 changes: 18 additions & 0 deletions libraries/botbuilder-dialogs/src/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @module botbuilder-dialogs
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
const Chinese = require('../vendor/cldr-data/main/zh/numbers.json');
const English = require('../vendor/cldr-data/main/en/numbers.json');
const German = require('../vendor/cldr-data/main/de/numbers.json');
const Dutch = require('../vendor/cldr-data/main/nl/numbers.json');
const Japanese = require('../vendor/cldr-data/main/ja/numbers.json');
const LikelySubtags = require('../vendor/cldr-data/supplemental/likelySubtags.json');
const NumberingSystem = require('../vendor/cldr-data/supplemental/numberingSystems.json');
const Portuguese = require('../vendor/cldr-data/main/pt/numbers.json');
const Spanish = require('../vendor/cldr-data/main/es/numbers.json');

export { Chinese, English, German, Dutch, Japanese, LikelySubtags, NumberingSystem, Portuguese, Spanish }
10 changes: 1 addition & 9 deletions libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@ import * as Recognizers from '@microsoft/recognizers-text-number';
import { Activity, InputHints, TurnContext } from 'botbuilder-core';
import { Prompt, PromptOptions, PromptRecognizerResult, PromptValidator } from './prompt';

import * as Chinese from 'cldr-data/main/zh/numbers.json';
import * as English from 'cldr-data/main/en/numbers.json';
import * as Dutch from 'cldr-data/main/nl/numbers.json';
import * as German from 'cldr-data/main/de/numbers.json';
import * as Japanese from 'cldr-data/main/ja/numbers.json';
import * as LikelySubtags from 'cldr-data/supplemental/likelySubtags.json';
import * as NumberingSystem from 'cldr-data/supplemental/numberingSystems.json';
import * as Portuguese from 'cldr-data/main/pt/numbers.json';
import * as Spanish from 'cldr-data/main/es/numbers.json';
import { Chinese, Dutch, English, German, Japanese, LikelySubtags, NumberingSystem, Portuguese, Spanish } from "../i18n";

import * as Globalize from 'globalize';
Globalize.load(
Expand Down
5 changes: 5 additions & 0 deletions libraries/botbuilder-dialogs/vendor/cldr-data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
All content in this directory (with the exception of this README.md) is derived from the [cldr-data](https://www.npmjs.com/package/cldr-data) package.

See the [NOTICE](../../NOTICE) file for further attribution details.

We are bundling a subset of the output of this dependency to reduce the install time and size.
Loading