Merge pull request #28125 from fullheightcoding/typos

Fixed some typos.
This commit is contained in:
Ryan Cavanaugh 2019-02-01 16:48:13 -08:00 committed by GitHub
commit 5bcf251f8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 188 additions and 188 deletions

View file

@ -4,7 +4,7 @@ import child_process = require("child_process");
type Author = {
displayNames: string[];
preferedName?: string;
preferredName?: string;
emails: string[];
};
@ -20,7 +20,7 @@ const authorsPath = path.resolve("../AUTHORS.md");
function getKnownAuthors(): Author[] {
const segmentRegExp = /\s?([^<]+)\s+<([^>]+)>/g;
const preferedNameRegeExp = /\s?#\s?([^#]+)$/;
const preferredNameRegeExp = /\s?#\s?([^#]+)$/;
const knownAuthors: Author[] = [];
if (!fs.existsSync(mailMapPath)) {
@ -37,13 +37,13 @@ function getKnownAuthors(): Author[] {
author.displayNames.push(match[1]);
author.emails.push(match[2]);
}
if (match = preferedNameRegeExp.exec(line)) {
author.preferedName = match[1];
if (match = preferredNameRegeExp.exec(line)) {
author.preferredName = match[1];
}
if (!author.emails) continue;
knownAuthors.push(author);
if (line.indexOf("#") > 0 && !author.preferedName) {
throw new Error("Could not match prefered name for: " + line);
if (line.indexOf("#") > 0 && !author.preferredName) {
throw new Error("Could not match preferred name for: " + line);
}
// console.log("===> line: " + line);
// console.log(JSON.stringify(author, undefined, 2));
@ -52,7 +52,7 @@ function getKnownAuthors(): Author[] {
}
function getAuthorName(author: Author) {
return author.preferedName || author.displayNames[0];
return author.preferredName || author.displayNames[0];
}
function getKnownAuthorMaps() {

View file

@ -5,7 +5,7 @@
import cp = require('child_process');
import fs = require('fs');
// Slice off 'node bisect-test.js' from the commandline args
// Slice off 'node bisect-test.js' from the command line args
var args = process.argv.slice(2);
function tsc(tscArgs: string, onExit: (exitCode: number) => void) {

View file

@ -30,7 +30,7 @@ var rawCompilerSources = "";
sourceFiles.forEach(f=> {
rawCompilerSources += "\r\n" + fs.readFileSync(path.join(tsSourceDir, f)).toString();
});
var compilerSoruces = `var compilerSources = ${JSON.stringify(rawCompilerSources) };`;
var compilerSources = `var compilerSources = ${JSON.stringify(rawCompilerSources) };`;
// .js code for the compiler, what we are actually testing
var rawCompilerJavaScript = fs.readFileSync(path.join(tsBuildDir, "tsc.js")).toString();
@ -38,7 +38,7 @@ rawCompilerJavaScript = rawCompilerJavaScript.replace("ts.executeCommandLine(ts.
// lib.d.ts sources
var rawLibSources = fs.readFileSync(path.join(tsBuildDir, "lib.d.ts")).toString();
var libSoruces = `var libSources = ${JSON.stringify(rawLibSources) };`;
var libSources = `var libSources = ${JSON.stringify(rawLibSources) };`;
// write test output
if (!fs.existsSync(testOutputDir)) {
@ -48,7 +48,7 @@ if (!fs.existsSync(testOutputDir)) {
// 1. compiler ts sources, used to test
fs.writeFileSync(
path.join(testOutputDir, "compilerSources.js"),
`${ compilerSoruces } \r\n ${ libSoruces }`);
`${ compilerSources } \r\n ${ libSources }`);
// 2. the compiler js sources + a call the compiler
fs.writeFileSync(

View file

@ -1,177 +1,177 @@
import * as fs from "fs";
import * as path from "path";
import * as xml2js from "xml2js";
function main(): void {
const args = process.argv.slice(2);
if (args.length !== 3) {
console.log("Usage:");
console.log("\tnode generateLocalizedDiagnosticMessages.js <lcl source directory> <output directory> <generated diagnostics map file>");
return;
}
const inputPath = args[0];
const outputPath = args[1];
const diagnosticsMapFilePath = args[2];
// generate the lcg file for enu
generateLCGFile();
// generate other langs
fs.readdir(inputPath, (err, files) => {
handleError(err);
files.forEach(visitDirectory);
});
return;
function visitDirectory(name: string) {
const inputFilePath = path.join(inputPath, name, "diagnosticMessages", "diagnosticMessages.generated.json.lcl");
fs.readFile(inputFilePath, (err, data) => {
handleError(err);
xml2js.parseString(data.toString(), (err, result) => {
handleError(err);
if (!result || !result.LCX || !result.LCX.$ || !result.LCX.$.TgtCul) {
console.error("Unexpected XML file structure. Expected to find result.LCX.$.TgtCul.");
process.exit(1);
}
const outputDirectoryName = getPreferedLocaleName(result.LCX.$.TgtCul).toLowerCase();
if (!outputDirectoryName) {
console.error(`Invalid output locale name for '${result.LCX.$.TgtCul}'.`);
process.exit(1);
}
writeFile(path.join(outputPath, outputDirectoryName, "diagnosticMessages.generated.json"), xmlObjectToString(result));
});
});
}
/**
* A locale name is based on the language tagging conventions of RFC 4646 (Windows Vista
* and later), and is represented by LOCALE_SNAME.
* Generally, the pattern <language>-<REGION> is used. Here, language is a lowercase ISO 639
* language code. The codes from ISO 639-1 are used when available. Otherwise, codes from
* ISO 639-2/T are used. REGION specifies an uppercase ISO 3166-1 country/region identifier.
* For example, the locale name for English (United States) is "en-US" and the locale name
* for Divehi (Maldives) is "dv-MV".
*
* If the locale is a neutral locale (no region), the LOCALE_SNAME value follows the
* pattern <language>. If it is a neutral locale for which the script is significant, the
* pattern is <language>-<Script>.
*
* More at https://msdn.microsoft.com/en-us/library/windows/desktop/dd373814(v=vs.85).aspx
*
* Most of the languages we support are neutral locales, so we want to use the language name.
* There are three exceptions, zh-CN, zh-TW and pt-BR.
*/
function getPreferedLocaleName(localeName: string) {
switch (localeName) {
case "zh-CN":
case "zh-TW":
case "pt-BR":
return localeName;
default:
return localeName.split("-")[0];
}
}
function handleError(err: null | object) {
if (err) {
console.error(err);
process.exit(1);
}
}
function xmlObjectToString(o: any) {
const out: any = {};
for (const item of o.LCX.Item[0].Item[0].Item) {
let ItemId = item.$.ItemId;
let val = item.Str[0].Tgt ? item.Str[0].Tgt[0].Val[0] : item.Str[0].Val[0];
if (typeof ItemId !== "string" || typeof val !== "string") {
console.error("Unexpected XML file structure");
process.exit(1);
}
if (ItemId.charAt(0) === ";") {
ItemId = ItemId.slice(1); // remove leading semicolon
}
val = val.replace(/]5D;/, "]"); // unescape `]`
out[ItemId] = val;
}
return JSON.stringify(out, undefined, 2);
}
function ensureDirectoryExists(directoryPath: string, action: () => void) {
fs.exists(directoryPath, exists => {
if (!exists) {
const basePath = path.dirname(directoryPath);
if (basePath !== directoryPath) {
return ensureDirectoryExists(basePath, () => fs.mkdir(directoryPath, action));
}
}
action();
});
}
function writeFile(fileName: string, contents: string) {
ensureDirectoryExists(path.dirname(fileName), () => {
fs.writeFile(fileName, contents, handleError);
});
}
function objectToList(o: Record<string, string>) {
const list: { key: string, value: string }[] = [];
for (const key in o) {
list.push({ key, value: o[key] });
}
return list;
}
function generateLCGFile() {
return fs.readFile(diagnosticsMapFilePath, (err, data) => {
handleError(err);
writeFile(
path.join(outputPath, "enu", "diagnosticMessages.generated.json.lcg"),
getLCGFileXML(
objectToList(JSON.parse(data.toString()))
.sort((a, b) => a.key > b.key ? 1 : -1) // lcg sorted by property keys
.reduce((s, { key, value }) => s + getItemXML(key, value), "")
));
});
function getItemXML(key: string, value: string) {
// escape entrt value
value = value.replace(/]/, "]5D;");
return `
<Item ItemId=";${key}" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[${value}]]></Val>
</Str>
<Disp Icon="Str" />
</Item>`;
}
function getLCGFileXML(items: string) {
return `<?xml version="1.0" encoding="utf-8"?>
<LCX SchemaVersion="6.0" Name="diagnosticMessages.generated.json" PsrId="306" FileType="1" SrcCul="en-US" xmlns="http://schemas.microsoft.com/locstudio/2006/6/lcx">
<OwnedComments>
<Cmt Name="Dev" />
<Cmt Name="LcxAdmin" />
<Cmt Name="Rccx" />
</OwnedComments>
<Item ItemId=";String Table" ItemType="0" PsrId="306" Leaf="false">
<Disp Icon="Expand" Expand="true" Disp="true" LocTbl="false" />
<Item ItemId=";Strings" ItemType="0" PsrId="306" Leaf="false">
<Disp Icon="Str" Disp="true" LocTbl="false" />${items}
</Item>
</Item>
</LCX>`;
}
}
}
main();
import * as fs from "fs";
import * as path from "path";
import * as xml2js from "xml2js";
function main(): void {
const args = process.argv.slice(2);
if (args.length !== 3) {
console.log("Usage:");
console.log("\tnode generateLocalizedDiagnosticMessages.js <lcl source directory> <output directory> <generated diagnostics map file>");
return;
}
const inputPath = args[0];
const outputPath = args[1];
const diagnosticsMapFilePath = args[2];
// generate the lcg file for enu
generateLCGFile();
// generate other langs
fs.readdir(inputPath, (err, files) => {
handleError(err);
files.forEach(visitDirectory);
});
return;
function visitDirectory(name: string) {
const inputFilePath = path.join(inputPath, name, "diagnosticMessages", "diagnosticMessages.generated.json.lcl");
fs.readFile(inputFilePath, (err, data) => {
handleError(err);
xml2js.parseString(data.toString(), (err, result) => {
handleError(err);
if (!result || !result.LCX || !result.LCX.$ || !result.LCX.$.TgtCul) {
console.error("Unexpected XML file structure. Expected to find result.LCX.$.TgtCul.");
process.exit(1);
}
const outputDirectoryName = getPreferredLocaleName(result.LCX.$.TgtCul).toLowerCase();
if (!outputDirectoryName) {
console.error(`Invalid output locale name for '${result.LCX.$.TgtCul}'.`);
process.exit(1);
}
writeFile(path.join(outputPath, outputDirectoryName, "diagnosticMessages.generated.json"), xmlObjectToString(result));
});
});
}
/**
* A locale name is based on the language tagging conventions of RFC 4646 (Windows Vista
* and later), and is represented by LOCALE_SNAME.
* Generally, the pattern <language>-<REGION> is used. Here, language is a lowercase ISO 639
* language code. The codes from ISO 639-1 are used when available. Otherwise, codes from
* ISO 639-2/T are used. REGION specifies an uppercase ISO 3166-1 country/region identifier.
* For example, the locale name for English (United States) is "en-US" and the locale name
* for Divehi (Maldives) is "dv-MV".
*
* If the locale is a neutral locale (no region), the LOCALE_SNAME value follows the
* pattern <language>. If it is a neutral locale for which the script is significant, the
* pattern is <language>-<Script>.
*
* More at https://msdn.microsoft.com/en-us/library/windows/desktop/dd373814(v=vs.85).aspx
*
* Most of the languages we support are neutral locales, so we want to use the language name.
* There are three exceptions, zh-CN, zh-TW and pt-BR.
*/
function getPreferredLocaleName(localeName: string) {
switch (localeName) {
case "zh-CN":
case "zh-TW":
case "pt-BR":
return localeName;
default:
return localeName.split("-")[0];
}
}
function handleError(err: null | object) {
if (err) {
console.error(err);
process.exit(1);
}
}
function xmlObjectToString(o: any) {
const out: any = {};
for (const item of o.LCX.Item[0].Item[0].Item) {
let ItemId = item.$.ItemId;
let val = item.Str[0].Tgt ? item.Str[0].Tgt[0].Val[0] : item.Str[0].Val[0];
if (typeof ItemId !== "string" || typeof val !== "string") {
console.error("Unexpected XML file structure");
process.exit(1);
}
if (ItemId.charAt(0) === ";") {
ItemId = ItemId.slice(1); // remove leading semicolon
}
val = val.replace(/]5D;/, "]"); // unescape `]`
out[ItemId] = val;
}
return JSON.stringify(out, undefined, 2);
}
function ensureDirectoryExists(directoryPath: string, action: () => void) {
fs.exists(directoryPath, exists => {
if (!exists) {
const basePath = path.dirname(directoryPath);
if (basePath !== directoryPath) {
return ensureDirectoryExists(basePath, () => fs.mkdir(directoryPath, action));
}
}
action();
});
}
function writeFile(fileName: string, contents: string) {
ensureDirectoryExists(path.dirname(fileName), () => {
fs.writeFile(fileName, contents, handleError);
});
}
function objectToList(o: Record<string, string>) {
const list: { key: string, value: string }[] = [];
for (const key in o) {
list.push({ key, value: o[key] });
}
return list;
}
function generateLCGFile() {
return fs.readFile(diagnosticsMapFilePath, (err, data) => {
handleError(err);
writeFile(
path.join(outputPath, "enu", "diagnosticMessages.generated.json.lcg"),
getLCGFileXML(
objectToList(JSON.parse(data.toString()))
.sort((a, b) => a.key > b.key ? 1 : -1) // lcg sorted by property keys
.reduce((s, { key, value }) => s + getItemXML(key, value), "")
));
});
function getItemXML(key: string, value: string) {
// escape entrt value
value = value.replace(/]/, "]5D;");
return `
<Item ItemId=";${key}" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[${value}]]></Val>
</Str>
<Disp Icon="Str" />
</Item>`;
}
function getLCGFileXML(items: string) {
return `<?xml version="1.0" encoding="utf-8"?>
<LCX SchemaVersion="6.0" Name="diagnosticMessages.generated.json" PsrId="306" FileType="1" SrcCul="en-US" xmlns="http://schemas.microsoft.com/locstudio/2006/6/lcx">
<OwnedComments>
<Cmt Name="Dev" />
<Cmt Name="LcxAdmin" />
<Cmt Name="Rccx" />
</OwnedComments>
<Item ItemId=";String Table" ItemType="0" PsrId="306" Leaf="false">
<Disp Icon="Expand" Expand="true" Disp="true" LocTbl="false" />
<Item ItemId=";Strings" ItemType="0" PsrId="306" Leaf="false">
<Disp Icon="Str" Disp="true" LocTbl="false" />${items}
</Item>
</Item>
</LCX>`;
}
}
}
main();