Add i18n for string literals from files in common folder (#849)

This commit is contained in:
Yuri Skorokhodov 2018-12-03 18:21:37 +03:00 коммит произвёл GitHub
Родитель 4bb027fd74
Коммит e2644f37a7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 77 добавлений и 69 удалений

Просмотреть файл

@ -284,14 +284,14 @@ gulp.task('add-i18n', function () {
// Gathers all strings to Transifex readable .xliff file for translating and pushes them to Transifex
gulp.task('transifex-push', ['build'], function () {
return gulp.src(['package.nls.json', 'out/nls.metadata.header.json','out/nls.metadata.json'])
return gulp.src(['package.nls.json', 'nls.metadata.header.json','nls.metadata.json'])
.pipe(nls.createXlfFiles(transifexProjectName, transifexExtensionName))
.pipe(nls.pushXlfFiles(transifexApiHostname, transifexApiName, transifexApiToken));
});
// Creates Transifex readable .xliff file and saves it locally
gulp.task('transifex-push-test', ['build'], function() {
return gulp.src(['package.nls.json', 'out/nls.metadata.header.json','out/nls.metadata.json'])
return gulp.src(['package.nls.json', 'nls.metadata.header.json','nls.metadata.json'])
.pipe(nls.createXlfFiles(transifexProjectName, transifexExtensionName))
.pipe(gulp.dest(path.join('..', `${transifexExtensionName}-push-test`)));
});

Просмотреть файл

@ -10,6 +10,8 @@ import {ISpawnResult} from "./node/childProcess";
import {HostPlatform, HostPlatformId} from "./hostPlatform";
import {ErrorHelper} from "./error/errorHelper";
import {InternalErrorCode} from "./error/internalErrorCode";
import * as nls from "vscode-nls";
const localize = nls.loadMessageBundle();
export enum CommandVerbosity {
OUTPUT,
@ -110,11 +112,11 @@ export class CommandExecutor {
return Q.resolve(void 0);
}
}).then(() => {
this.logger.info("Packager stopped");
this.logger.info(localize("PackagerStopped", "Packager stopped"));
});
} else {
this.logger.warning("Packager not found");
this.logger.warning(localize("PackagerNotFound", "Packager not found"));
return Q.resolve<void>(void 0);
}
}
@ -216,13 +218,13 @@ export class CommandExecutor {
private static getCommandStatusString(command: string, status: CommandStatus) {
switch (status) {
case CommandStatus.Start:
return `Executing command: ${command}`;
return localize("ExecutingCommand", "Executing command: {0}", command);
case CommandStatus.End:
return `Finished executing: ${command}`;
return localize("FinishedExecutingCommand", "Finished executing: {0}", command);
default:
throw new Error("Unsupported command status");
throw new Error(localize("UnsupportedCommandStatus", "Unsupported command status"));
}
}
}

Просмотреть файл

@ -1,41 +1,43 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import * as nls from "vscode-nls";
const localize = nls.loadMessageBundle();
export const ERROR_STRINGS = {
"CommandFailed": "Error while executing command '{0}'",
"CommandFailedWithErrorCode": "Command '{0}' failed with error code {1}",
"ExpectedIntegerValue": "Expected an integer. Couldn't read {0}",
"PackagerStartFailed": "Error while executing React Native Packager.",
"IOSDeployNotFound": "Unable to find ios-deploy. Please make sure to install it globally('npm install -g ios-deploy')",
"DeviceNotPluggedIn": "Unable to mount developer disk image.",
"DeveloperDiskImgNotMountable": "Unable to mount developer disk image.",
"UnableToLaunchApplication": "Unable to launch application.",
"ApplicationLaunchTimedOut": "Timeout launching application. Is the device locked?",
"IOSSimulatorNotLaunchable": "Unable to launch iOS simulator. Try specifying a different target.",
"OpnPackagerLocationNotFound": "opn package location not found",
"PackageNotFound": "Attempting to find package {0} failed with error: {1}",
"PlatformNotSupported": "Platform '{0}' is not supported on host platform: {1}",
"ProjectVersionNotParsable": "Couldn't parse the version component of the package at {0}: version = {1}",
"ProjectVersionUnsupported": "Project version = {0}",
"ProjectVersionNotReadable": "Unable to read version = {0}",
"TelemetryInitializationFailed": "{0}. Couldn't initialize telemetry",
"ExtensionActivationFailed": "Failed to activate the React Native Tools extension",
"DebuggerStubLauncherFailed": "Failed to setup the stub launcher for the debugger",
"IntellisenseSetupFailed": "Failed to setup IntelliSense",
"NodeDebuggerConfigurationFailed": "Failed to configure the node debugger location for the debugger",
"FailedToStopPackagerOnExit": "Failed to stop the packager while closing React Native Tools",
"FailedToRunOnAndroid": "Failed to run the application in Android",
"FailedToRunOnIos": "Failed to run the application in iOS",
"FailedToRunExponent": "Failed to run the application in Exponent",
"FailedToPublishToExpHost": "Failed to publish the application to Exponent",
"FailedToStartPackager": "Failed to start the React Native packager",
"FailedToStopPackager": "Failed to stop the React Native packager",
"FailedToRestartPackager": "Failed to restart the React Native packager",
"DebuggingFailed": "Cannot debug application",
"DebuggingFailedInNodeWrapper": "Cannot debug application due to an error in the internal Node Debugger",
"RNTempFolderDeletionFailed": "Couldn't delete the temporary folder {0}",
"CouldNotFindLocationOfNodeDebugger": "Couldn't find the location of the node-debugger extension",
"PackagerRunningInDifferentPort": "A packager cannot be started on port {0} because a packager process is already running on port {1}",
"ErrorWhileProcessingMessageInIPMSServer": "An error ocurred while handling message: {0}",
"ErrorNoPipeFound": "Unable to set up communication with VSCode react-native extension. Is this a react-native project, and have you made sure that the react-native npm package is installed at the root?",
"CommandFailed": localize("CommandFailed", "Error while executing command '{0}'"),
"CommandFailedWithErrorCode": localize("CommandFailedWithErrorCode", "Command '{0}' failed with error code {1}"),
"ExpectedIntegerValue": localize("ExpectedIntegerValue", "Expected an integer. Couldn't read {0}"),
"PackagerStartFailed": localize("PackagerStartFailed", "Error while executing React Native Packager."),
"IOSDeployNotFound": localize("IOSDeployNotFound", "Unable to find ios-deploy. Please make sure to install it globally('npm install -g ios-deploy')"),
"DeviceNotPluggedIn": localize("DeviceNotPluggedIn", "Unable to mount developer disk image."),
"DeveloperDiskImgNotMountable": localize("DeveloperDiskImgNotMountable", "Unable to mount developer disk image."),
"UnableToLaunchApplication": localize("UnableToLaunchApplication", "Unable to launch application."),
"ApplicationLaunchTimedOut": localize("ApplicationLaunchTimedOut", "Timeout launching application. Is the device locked?"),
"IOSSimulatorNotLaunchable": localize("IOSSimulatorNotLaunchable", "Unable to launch iOS simulator. Try specifying a different target."),
"OpnPackagerLocationNotFound": localize("OpnPackagerLocationNotFound", "Opn package location not found"),
"PackageNotFound": localize("PackageNotFound", "Attempting to find package {0} failed with error: {1}"),
"PlatformNotSupported": localize("PlatformNotSupported", "Platform '{0}' is not supported on host platform: {1}"),
"ProjectVersionNotParsable": localize("ProjectVersionNotParsable", "Couldn't parse the version component of the package at {0}: version = {1}"),
"ProjectVersionUnsupported": localize("ProjectVersionUnsupported", "Project version = {0}"),
"ProjectVersionNotReadable": localize("ProjectVersionNotReadable", "Unable to read version = {0}"),
"TelemetryInitializationFailed": localize("TelemetryInitializationFailed", "{0}. Couldn't initialize telemetry"),
"ExtensionActivationFailed": localize("ExtensionActivationFailed", "Failed to activate the React Native Tools extension"),
"DebuggerStubLauncherFailed": localize("DebuggerStubLauncherFailed", "Failed to setup the stub launcher for the debugger"),
"IntellisenseSetupFailed": localize("IntellisenseSetupFailed", "Failed to setup IntelliSense"),
"NodeDebuggerConfigurationFailed": localize("NodeDebuggerConfigurationFailed", "Failed to configure the node debugger location for the debugger"),
"FailedToStopPackagerOnExit": localize("FailedToStopPackagerOnExit", "Failed to stop the packager while closing React Native Tools"),
"FailedToRunOnAndroid": localize("FailedToRunOnAndroid", "Failed to run the application in Android"),
"FailedToRunOnIos": localize("FailedToRunOnIos", "Failed to run the application in iOS"),
"FailedToRunExponent": localize("FailedToRunExponent", "Failed to run the application in Exponent"),
"FailedToPublishToExpHost": localize("FailedToRunExponent", "Failed to publish the application to Exponent"),
"FailedToStartPackager": localize("FailedToStartPackager", "Failed to start the React Native packager"),
"FailedToStopPackager": localize("FailedToStopPackager", "Failed to stop the React Native packager"),
"FailedToRestartPackager": localize("FailedToRestartPackager", "Failed to restart the React Native packager"),
"DebuggingFailed": localize("DebuggingFailed", "Cannot debug application"),
"DebuggingFailedInNodeWrapper": localize("DebuggingFailedInNodeWrapper", "Cannot debug application due to an error in the internal Node Debugger"),
"RNTempFolderDeletionFailed": localize("RNTempFolderDeletionFailed", "Couldn't delete the temporary folder {0}"),
"CouldNotFindLocationOfNodeDebugger": localize("CouldNotFindLocationOfNodeDebugger", "Couldn't find the location of the node-debugger extension"),
"PackagerRunningInDifferentPort": localize("PackagerRunningInDifferentPort", "A packager cannot be started on port {0} because a packager process is already running on port {1}"),
"ErrorWhileProcessingMessageInIPMSServer": localize("ErrorWhileProcessingMessageInIPMSServer", "An error ocurred while handling message: {0}"),
"ErrorNoPipeFound": localize("ErrorNoPipeFound", "Unable to set up communication with VSCode react-native extension. Is this a react-native project, and have you made sure that the react-native npm package is installed at the root?"),
};

Просмотреть файл

@ -5,6 +5,8 @@ import * as pathModule from "path";
import * as Q from "q";
import {FileSystem} from "./fileSystem";
import * as nls from "vscode-nls";
const localize = nls.loadMessageBundle();
interface IPackageDependencyDict {
[packageName: string]: string;
@ -49,7 +51,7 @@ export class Package {
return this.parseProperty("version").then(version =>
typeof version === "string"
? version
: Q.reject<string>(`Couldn't parse the version component of the package at ${this.informationJsonFilePath()}: version = ${version}`));
: Q.reject<string>(localize("CouldNotParseVersion", "Couldn't parse the version component of the package at {0}: version = {1}", this.informationJsonFilePath(), version)));
}
public setMainFile(value: string): Q.Promise<void> {

Просмотреть файл

@ -3,6 +3,8 @@
import * as Q from "q";
import {ISpawnResult} from "./node/childProcess";
import * as nls from "vscode-nls";
const localize = nls.loadMessageBundle();
export type PatternToFailure = {
pattern: string | RegExp,
@ -43,11 +45,8 @@ export class OutputVerifier {
}
}).then(successPatterns => {
if (!this.areAllSuccessPatternsPresent(successPatterns)) { // If we don't find all the success patterns, we also fail
const message =
`Unknown error: not all success patterns were matched.
It means that "react-native run-${this.platformName}" command failed. \
Please, check the View -> Toggle Output -> React Native, \
View -> Toggle Output -> React Native: Run ${this.platformName} output windows.`;
const message = localize("ErrorMessageNotAllSuccessPatternsMatched",
"Unknown error: not all success patterns were matched. \n It means that \"react-native run-{0}\" command failed. \n Please, check the View -> Toggle Output -> React Native, \n View -> Toggle Output -> React Native: Run {1} output windows.", this.platformName, this.platformName);
return Q.reject<void>(new Error(message));
} // else we found all the success patterns, so we succeed
return Q.resolve(void 0);

Просмотреть файл

@ -20,6 +20,8 @@ import * as path from "path";
import * as XDL from "../extension/exponent/xdlInterface";
import * as semver from "semver";
import { FileSystem } from "./node/fileSystem";
import * as nls from "vscode-nls";
const localize = nls.loadMessageBundle();
export class Packager {
public static DEFAULT_PORT = 8081;
@ -89,7 +91,7 @@ export class Packager {
return args;
})
.catch(() => {
this.logger.warning("Couldn't read packager's options from exp.json, continue...");
this.logger.warning(localize("CouldNotReadPackagerOptions", "Couldn't read packager's options from exp.json, continue..."));
return args;
});
@ -128,7 +130,7 @@ export class Packager {
REACT_EDITOR: failedRNVersions.indexOf(rnVersion) < 0 ? "code" : this.openFileAtLocationCommand(),
});
this.logger.info("Starting Packager");
this.logger.info(localize("StartingPackager", "Starting Packager"));
// The packager will continue running while we debug the application, so we can"t
// wait for this command to finish
@ -147,12 +149,12 @@ export class Packager {
.then(() => {
this.packagerStatusIndicator.updatePackagerStatus(PackagerStatus.PACKAGER_STARTED);
if (executedStartPackagerCmd) {
this.logger.info("Packager started.");
this.logger.info(localize("PackagerStarted", "Packager started."));
this.packagerStatus = PackagerStatus.PACKAGER_STARTED;
} else {
this.logger.info("Packager is already running.");
this.logger.info(localize("PackagerIsAlreadyRunning", "Packager is already running."));
if (!this.packagerProcess) {
this.logger.warning(ErrorHelper.getWarning("React Native Packager running outside of VS Code. If you want to debug please use the 'Attach to packager' option"));
this.logger.warning(ErrorHelper.getWarning(localize("PackagerRunningOutsideVSCode", "React Native Packager running outside of VS Code. If you want to debug please use the 'Attach to packager' option")));
}
}
});
@ -165,14 +167,14 @@ export class Packager {
if (running) {
if (!this.packagerProcess) {
if (!silent) {
this.logger.warning(ErrorHelper.getWarning("Packager is still running. If the packager was started outside VS Code, please quit the packager process using the task manager."));
this.logger.warning(ErrorHelper.getWarning(localize("PackagerIsStillRunning", "Packager is still running. If the packager was started outside VS Code, please quit the packager process using the task manager.")));
}
return Q.resolve<void>(void 0);
}
return this.killPackagerProcess();
} else {
if (!silent) {
this.logger.warning(ErrorHelper.getWarning("Packager is not running"));
this.logger.warning(ErrorHelper.getWarning(localize("PackagerIsNotRunning", "Packager is not running")));
}
return Q.resolve<void>(void 0);
}
@ -191,13 +193,13 @@ export class Packager {
.then(running => {
if (running) {
if (!this.packagerProcess) {
this.logger.warning(ErrorHelper.getWarning("Packager is still running. If the packager was started outside VS Code, please quit the packager process using the task manager. Then try the restart packager again."));
this.logger.warning(ErrorHelper.getWarning(localize("PackagerIsStillRunning", "Packager is still running. If the packager was started outside VS Code, please quit the packager process using the task manager. Then try the restart packager again.")));
return Q.resolve<boolean>(false);
}
return this.killPackagerProcess().then(() => Q.resolve<boolean>(true));
} else {
this.logger.warning(ErrorHelper.getWarning("Packager is not running"));
this.logger.warning(ErrorHelper.getWarning(localize("PackagerIsNotRunning", "Packager is not running")));
return Q.resolve<boolean>(true);
}
})
@ -231,15 +233,15 @@ export class Packager {
} else if (exists[1]) {
bundleName = `index.${platform}.bundle`;
} else {
this.logger.info(`Entry point doesn't exist neither at index.js nor index.${platform}.js. Skip prewarming...`);
this.logger.info(localize("EntryPointDoesntExist", "Entry point doesn't exist neither at index.js nor index.{0}.js. Skip prewarming...", platform));
return;
}
const bundleURL = `http://${this.getHost()}/${bundleName}?platform=${platform}`;
this.logger.info("About to get: " + bundleURL);
this.logger.info(localize("AboutToGetURL", "About to get: {0}", bundleURL));
return Request.request(bundleURL, true)
.then(() => {
this.logger.warning("The Bundle Cache was prewarmed.");
this.logger.warning(localize("BundleCacheWasPrewarmed", "The Bundle Cache was prewarmed."));
});
})
.catch(() => {
@ -262,7 +264,7 @@ export class Packager {
private awaitStart(retryCount = 30, delay = 2000): Q.Promise<boolean> {
let pu: PromiseUtil = new PromiseUtil();
return pu.retryAsync(() => this.isRunning(), (running) => running, retryCount, delay, "Could not start the packager.");
return pu.retryAsync(() => this.isRunning(), (running) => running, retryCount, delay, localize("CouldNotStartPackager", "Could not start the packager."));
}
private findOpnPackage(): Q.Promise<string> {
@ -282,9 +284,9 @@ export class Packager {
fsHelper.exists(fsPath).then(exists =>
exists
? Q.resolve(fsPath)
: Q.reject<string>("opn package location not found"))));
: Q.reject<string>(localize("OpnPackageLocationNotFound", "opn package location not found")))));
} catch (err) {
return Q.reject<string>("The package 'opn' was not found. " + err);
return Q.reject<string>(localize("ThePackageOpnWasNotFound", "The package 'opn' was not found. ") + err);
}
}
@ -313,7 +315,7 @@ export class Packager {
}
private killPackagerProcess(): Q.Promise<void> {
this.logger.info("Stopping Packager");
this.logger.info(localize("StoppingPackager", "Stopping Packager"));
return new CommandExecutor(this.projectPath, this.logger).killReactPackager(this.packagerProcess).then(() => {
this.packagerProcess = undefined;
@ -322,10 +324,10 @@ export class Packager {
return helper.isExpoApp(false)
.then((isExpo) => {
if (isExpo) {
this.logger.debug("Stopping Exponent");
this.logger.debug(localize("StoppingExponent", "Stopping Exponent"));
return XDL.stopAll(this.projectPath)
.then(() => {
this.logger.debug("Exponent Stopped");
this.logger.debug(localize("ExponentStopped", "Exponent Stopped"));
})
.catch((err) => {
if (err.code === "NOT_LOGGED_IN") {

Просмотреть файл

@ -5,7 +5,8 @@ import * as os from "os";
import {ErrorHelper} from "./error/errorHelper";
import {HostPlatform} from "./hostPlatform";
import {InternalErrorCode} from "./error/internalErrorCode";
import * as nls from "vscode-nls";
const localize = nls.loadMessageBundle();
/**
* Defines the identifiers of all the mobile target platforms React Native supports.
*/
@ -32,7 +33,7 @@ export class TargetPlatformHelper {
case "wpf":
return TargetPlatformId.WINDOWS;
default:
throw new Error(`The target platform ${platformName} is not supported.`);
throw new Error( localize("TargetPlatformIsNotSupported", "The target platform {0} is not supported.", platformName));
}
}