Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b187d16
src: externalized messages support, 2nd pass
jasnell Jan 7, 2016
6401743
src: externalize debugger.js messages
jasnell Jan 8, 2016
3fcddc4
src: externalized _debug_agent.js messages
jasnell Jan 8, 2016
503092e
test, src: add test-internal-messages.js, address nits
jasnell Jan 8, 2016
4359ec9
src: fix lint issue
jasnell Jan 8, 2016
c48ec49
src: externalize lib/_http_agent.js messages
jasnell Jan 8, 2016
112b084
src: externalize _http_client.js messages
jasnell Jan 8, 2016
8538841
src: externalize _http_outgoing.js messages, address nits
jasnell Jan 8, 2016
ff170ed
src: remove NODE_ prefix from message identifiers
jasnell Jan 8, 2016
bdca377
src: externalize _http_server.js messages
jasnell Jan 8, 2016
b270571
src: externalize _linklist.js messages
jasnell Jan 8, 2016
1b1e228
src: externalize _stream_readable.js messages
jasnell Jan 8, 2016
ee2228d
src: externalize _stream_transform.js messages
jasnell Jan 8, 2016
71d1fae
src: externalize _stream_wrap.js messages
jasnell Jan 8, 2016
eb882bc
src: externalized _stream_writable.js messages
jasnell Jan 8, 2016
0de2994
tools: enable restParams for eslint
jasnell Jan 8, 2016
0f0298e
src: externalize _tls_legacy.js messages, refactor debug
jasnell Jan 8, 2016
f095579
src: externalize _tls_wrap.js messages
jasnell Jan 9, 2016
62f6ec9
src: externalize assert.js messages
jasnell Jan 9, 2016
5d73fb3
src: externalize buffer.js messages
jasnell Jan 9, 2016
b1bc41f
src: externalize child-process.js messages
jasnell Jan 9, 2016
018472b
src: externalize cluster.js messages
jasnell Jan 9, 2016
7aa5d4f
src: externalize console.js messages
jasnell Jan 9, 2016
20640e8
src: externalize crypto.js messages
jasnell Jan 9, 2016
78b9090
src: externalize dgram.js messages
jasnell Jan 9, 2016
82679a5
src: externalize dns.js messages
jasnell Jan 9, 2016
649721b
src: externalize events.js messages
jasnell Jan 9, 2016
11b96dc
src: externalize fs.js messages
jasnell Jan 9, 2016
abc08a9
src: externalize http.js messages
jasnell Jan 9, 2016
0b9c3af
src: externalize https.js messages
jasnell Jan 9, 2016
0e8b40a
src: externalize module.js messages
jasnell Jan 9, 2016
650ab1c
src: externalize net.js messages
jasnell Jan 9, 2016
d89c414
src: externalize os.js messages
jasnell Jan 9, 2016
181e5c6
src: externalize path.js messages
jasnell Jan 9, 2016
b1ca5e1
src: externalize punycode.js messages
jasnell Jan 9, 2016
55fa5d8
src: externalize readline.js messages
jasnell Jan 9, 2016
5f4861d
src: externalize repl.js messages
jasnell Jan 9, 2016
67185ec
src: externalize string_decoder.js messages
jasnell Jan 9, 2016
f0c5782
src: externalize sys.js messages
jasnell Jan 9, 2016
497329f
src: externalized timers.js messages
jasnell Jan 9, 2016
e142e8a
src: externalize tls.js messages
jasnell Jan 9, 2016
678e8e8
src: externalize url.js messages
jasnell Jan 9, 2016
0a197c8
src: externalize util.js messages
jasnell Jan 9, 2016
cd4db97
src: externalize zlib.js messages
jasnell Jan 9, 2016
61240ea
src: externalize internal/child_process.js messages
jasnell Jan 9, 2016
259a36d
src: externalize internal/repl.js messages
jasnell Jan 9, 2016
96aa61f
src: externalize internal/socket_list.js messages
jasnell Jan 9, 2016
b885af3
src: externalize internal/v8_prof_polyfill.js messages
jasnell Jan 9, 2016
924aa9d
src: externalize additional messages missed
jasnell Jan 9, 2016
086bd73
src: avoid runtime calls
jasnell Jan 9, 2016
46fcb2d
src: code cleanup
jasnell Jan 9, 2016
edcb53b
src: refactor I18N.Error, I18N.TypeError and I18N.RangeError
jasnell Jan 10, 2016
42b7c7f
src: internal/messages.js code cleanup
jasnell Jan 10, 2016
21b1d95
src: begin externalizing src/* messages
jasnell Jan 10, 2016
5545855
src: externalize more native strings
jasnell Jan 11, 2016
08866a3
src: support varargs in messages, externalize src/node_dtrace.cc
jasnell Jan 11, 2016
44cc074
src: refactor macros to make env explicit, externalize node_file.cc
jasnell Jan 11, 2016
a5d97de
src: externalize additional src/*.cc files
jasnell Jan 11, 2016
9fc6ec1
src: externalize remaining errors in src/*.cc
jasnell Jan 11, 2016
92df8e6
src: externalize node.cc messages and print help, cleanups
jasnell Jan 11, 2016
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
Prev Previous commit
src: externalize node.cc messages and print help, cleanups
  • Loading branch information
jasnell committed Jan 11, 2016
commit 92df8e618618e4f71930a73c477f1a8b15556a40
11 changes: 6 additions & 5 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void Environment::PrintSyncTrace() const {
Local<v8::StackTrace> stack =
StackTrace::CurrentStackTrace(isolate(), 10, StackTrace::kDetailed);

fprintf(stderr, "(node:%d) WARNING: Detected use of sync API\n", getpid());
fprintf(stderr, STR_SYNC_WARNING, getpid());

for (int i = 0; i < stack->GetFrameCount() - 1; i++) {
Local<StackFrame> stack_frame = stack->GetFrame(i);
Expand All @@ -38,10 +38,10 @@ void Environment::PrintSyncTrace() const {

if (stack_frame->IsEval()) {
if (stack_frame->GetScriptId() == Message::kNoScriptIdInfo) {
fprintf(stderr, " at [eval]:%i:%i\n", line_number, column);
fprintf(stderr, " " STR_AT " [eval]:%i:%i\n", line_number, column);
} else {
fprintf(stderr,
" at [eval] (%s:%i:%i)\n",
" " STR_AT " [eval] (%s:%i:%i)\n",
*script_name,
line_number,
column);
Expand All @@ -50,10 +50,11 @@ void Environment::PrintSyncTrace() const {
}

if (fn_name_s.length() == 0) {
fprintf(stderr, " at %s:%i:%i\n", *script_name, line_number, column);
fprintf(stderr, " " STR_AT " %s:%i:%i\n",
*script_name, line_number, column);
} else {
fprintf(stderr,
" at %s (%s:%i:%i)\n",
" " STR_AT " %s (%s:%i:%i)\n",
*fn_name_s,
*script_name,
line_number,
Expand Down
169 changes: 120 additions & 49 deletions src/messages/en/messages.h
Original file line number Diff line number Diff line change
@@ -1,65 +1,137 @@
#ifndef SRC_NODE_MESSAGES_SRC_H_
#define SRC_NODE_MESSAGES_SRC_H_

// node --help output

#if HAVE_OPENSSL
#define NODE_HELP_OPENSSL \
" --tls-cipher-list=val use an alternative default TLS cipher list\n"
#else // !HAVE_OPENSSL
#define NODE_HELP_OPENSSL ""
#endif // HAVE_OPENSSL

#if defined(NODE_HAVE_I18N_SUPPORT)
#if !defined(NODE_HAVE_SMALL_ICU)
#define NODE_HELP_I18N_SMALL_ICU \
" note: linked-in ICU data is\n" \
" present.\n"
#else // defined(NODE_HAVE_SMALL_ICU)
#define NODE_HELP_I18N_SMALL_ICU ""
#endif // !defined(NODE_HAVE_SMALL_ICU)
#define NODE_HELP_I18N \
" --icu-data-dir=dir set ICU data load path to dir\n" \
" (overrides NODE_ICU_DATA)\n" \
NODE_HELP_I18N_SMALL_ICU

#define NODE_HELP_ICU_DATA \
"NODE_ICU_DATA data path for ICU (Intl object) data\n" \
" (will extend linked-in data)\n"

#else // !defined(NODE_HAVE_I18N_SUPPORT)
#define NODE_HELP_ICU_DATA ""
#define NODE_HELP_I18N ""
#endif // defined(NODE_HAVE_I18N_SUPPORT)

// Determine the path separator
#ifdef _WIN32
#define NODE_HELP_SEP ";"
#else
#define NODE_HELP_SEP ":"
#endif

#define STR_NODEHELP \
"Usage: node [options] [ -e script | script.js ] [arguments] \n" \
" node debug script.js [arguments] \n" \
"\n" \
"Options:\n" \
" -v, --version print Node.js version\n" \
" -e, --eval script evaluate script\n" \
" -p, --print evaluate script and print result\n" \
" -c, --check syntax check script without executing\n" \
" -i, --interactive always enter the REPL even if stdin\n" \
" does not appear to be a terminal\n" \
" -r, --require module to preload (option can be repeated)\n" \
" --no-deprecation silence deprecation warnings\n" \
" --throw-deprecation throw an exception anytime a deprecated " \
"function is used\n" \
" --trace-deprecation show stack traces on deprecations\n" \
" --trace-sync-io show stack trace when use of sync IO\n" \
" is detected after the first tick\n" \
" --track-heap-objects track heap object allocations for heap " \
"snapshots\n" \
" --prof-process process v8 profiler output generated\n" \
" using --prof\n" \
" --v8-options print v8 command line options\n" \
NODE_HELP_OPENSSL \
NODE_HELP_I18N \
"\n" \
"Environment variables:\n" \
"NODE_PATH '" NODE_HELP_SEP "'-separated list of " \
"directories\n" \
" prefixed to the module search path.\n" \
"NODE_DISABLE_COLORS set to 1 to disable colors in the REPL\n" \
NODE_HELP_ICU_DATA \
"NODE_REPL_HISTORY path to the persistent REPL history file\n" \
"\n" \
"Documentation can be found at https://nodejs.org/\n"

// Other messages ...

#define NODE_MESSAGE_UNKNOWN "(Message Unknown)"

#define NODE_DEPRECATE_MESSAGE(what, alternate) \
what " is deprecated. Use " alternate " instead."

#define STR_SYNC_WARNING "(node:%d) WARNING: Detected use of sync API\n"
#define STR_AT "at"
#define STR_OPENSSL_FIPS_FAIL "openssl fips failed: %s\n"
#define STR_PROCESS_TICKDOMAIN_NONFUNCTION \
"process._tickDomainCallback assigned to non-function\n"
#define STR_RAW_ENCODING_REMOVED \
"'raw' encoding (array of integers) has been removed. Use 'binary'.\n"
#define STR_MODULE_VERSION_MISMATCH \
"Module version mismatch. Expected %d, got %d."
#define STR_BINDING "Binding %s"
#define STR_NO_SUCH_MODULE "No such module: %s"
#define STR_NO_SUCH_MODULE_LINKED "No such module was linked: %s"
#define STR_DEBUGPORT_OUTOFRANGE "Debug port must be in range 1024 to 65535.\n"
#define STR_REQUIRES_ARGUMENT "%s: %s requires an argument\n"
#define STR_START_DEBUGGER_FAIL "Starting debugger on port %d failed\n"
#define STR_START_DEBUGGER_AGENT "Starting debugger agent.\n"
#define STR_BAD_OPTION "bad option"

// The messages used in src/*.cc
// These are used only within the Node.js native source
#define STR_CONVERT_ARGS_TO_UTF8_FAIL "Could not convert arguments to utf8."
#define STR_OUTOFMEMORY "Out of memory"
#define STR_CALLBACK_NOT_ASSIGNED \
"init callback is not assigned to a function"
#define STR_HOOKSSHOULDNOTBESET \
"hooks should not be set while also enabled"
#define STR_INITCALLBACK \
"init callback must be a function"
#define STR_INVALID_FILENAME \
"filename must be a valid string"
#define STR_INDEX_OUT_OF_RANGE \
"out of range index"
#define STR_ARGUMENT_BUFFER \
"argument should be a Buffer"
#define STR_ARGUMENT_STRING \
"Argument must be a string"
#define STR_ARGUMENT_ARRAYBUFFER \
"argument is not an ArrayBuffer"
#define STR_UNABLE_TO_SET_PROTOTYPE \
"Unable to set Object prototype"
#define STR_INVALID_HEX \
"Invalid hex string"
#define STR_OFFSET_OUTOFBOUNDS \
"Offset is out of bounds"
#define STR_LENGTH_OUTOFBOUNDS \
"length out of bounds"
#define STR_SANDBOX_OBJECT \
"sandbox argument must be an object."
#define STR_VMSCRIPT_AS_CONSTRUCTOR \
"Must call vm.Script as a constructor."
#define STR_CONTEXTIFIED_MUST_BE_OBJECT \
#define STR_CALLBACK_NOT_ASSIGNED "init callback is not assigned to a function"
#define STR_HOOKSSHOULDNOTBESET "hooks should not be set while also enabled"
#define STR_INITCALLBACK "init callback must be a function"
#define STR_INVALID_FILENAME "filename must be a valid string"
#define STR_INDEX_OUT_OF_RANGE "out of range index"
#define STR_ARGUMENT_BUFFER "argument should be a Buffer"
#define STR_ARGUMENT_STRING "Argument must be a string"
#define STR_ARGUMENT_ARRAYBUFFER "argument is not an ArrayBuffer"
#define STR_UNABLE_TO_SET_PROTOTYPE "Unable to set Object prototype"
#define STR_INVALID_HEX "Invalid hex string"
#define STR_OFFSET_OUTOFBOUNDS "Offset is out of bounds"
#define STR_LENGTH_OUTOFBOUNDS "length out of bounds"
#define STR_SANDBOX_OBJECT "sandbox argument must be an object."
#define STR_VMSCRIPT_AS_CONSTRUCTOR "Must call vm.Script as a constructor."
#define STR_CONTEXTIFIED_MUST_BE_OBJECT \
"contextifiedSandbox argument must be an object."
#define STR_SANDBOX_ARGUMENT_CONVERSION \
#define STR_SANDBOX_ARGUMENT_CONVERSION \
"sandbox argument must have been converted to a context."
#define STR_OPTIONS_OBJECT \
"options must be an object"
#define STR_TIMEOUT_POSITIVE \
"timeout must be a positive number"
#define STR_CANNOT_CALL_SCRIPT_METHODS \
#define STR_OPTIONS_OBJECT "options must be an object"
#define STR_TIMEOUT_POSITIVE "timeout must be a positive number"
#define STR_CANNOT_CALL_SCRIPT_METHODS \
"Script methods can only be called on script instances."
#define STR_SCRIPT_EXECUTION_TIMEDOUT \
"Script execution timed out."
#define STR_NOT_STRING_BUFFER \
"Not a string or buffer"
#define STR_NOT_BUFFER \
"Not a buffer"
#define STR_SSLV2_METHODS_DISABLED \
"SSLv2 methods disabled"
#define STR_SSLV3_METHODS_DISABLED \
"SSLv3 methods disabled"
#define STR_UNKNOWN_METHOD \
"Unknown method"
#define STR_SCRIPT_EXECUTION_TIMEDOUT "Script execution timed out."
#define STR_NOT_STRING_BUFFER "Not a string or buffer"
#define STR_NOT_BUFFER "Not a buffer"
#define STR_SSLV2_METHODS_DISABLED "SSLv2 methods disabled"
#define STR_SSLV3_METHODS_DISABLED "SSLv3 methods disabled"
#define STR_UNKNOWN_METHOD "Unknown method"
#define STR_BAD_PARAMETER "Bad parameter"
#define STR_PEM_READ_BIO "PEM_read_bio_PrivateKey"
#define STR_CTX_USE_PRIVATEKEY "SSL_CTX_use_PrivateKey"
Expand Down Expand Up @@ -694,8 +766,7 @@
"directory. This functionality is deprecated and will be removed soon.") \
XX(MODULE_REQUIREREPL_DEPRECATED, "Module.requireRepl is deprecated.") \
XX(NET_SERVER_CONNECTIONS_DEPRECATED, \
NODE_DEPRECATE_MESSAGE("Server.connections", \
"Server.getConnections")) \
NODE_DEPRECATE_MESSAGE("Server.connections", "Server.getConnections")) \
XX(NET_SERVER_CONNECTIONS_DEPRECATED_SET, \
"Server.connections property is deprecated.") \
XX(NET_SERVER_LISTENFD_DEPRECATED, \
Expand Down
77 changes: 13 additions & 64 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
process_object->Get(tick_callback_function_key).As<Function>();

if (!tick_callback_function->IsFunction()) {
fprintf(stderr, "process._tickDomainCallback assigned to non-function\n");
fprintf(stderr, STR_PROCESS_TICKDOMAIN_NONFUNCTION);
ABORT();
}

Expand Down Expand Up @@ -1417,8 +1417,7 @@ ssize_t DecodeBytes(Isolate* isolate,
HandleScope scope(isolate);

if (val->IsArray()) {
fprintf(stderr, "'raw' encoding (array of integers) has been removed. "
"Use 'binary'.\n");
fprintf(stderr, STR_RAW_ENCODING_REMOVED);
UNREACHABLE();
return -1;
}
Expand Down Expand Up @@ -2277,7 +2276,7 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
char errmsg[1024];
snprintf(errmsg,
sizeof(errmsg),
"Module version mismatch. Expected %d, got %d.",
STR_MODULE_VERSION_MISMATCH,
NODE_MODULE_VERSION, mp->nm_version);

// NOTE: `mp` is allocated inside of the shared library's memory, calling
Expand Down Expand Up @@ -2404,7 +2403,7 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {

// Append a string to process.moduleLoadList
char buf[1024];
snprintf(buf, sizeof(buf), "Binding %s", *module_v);
snprintf(buf, sizeof(buf), STR_BINDING, *module_v);

Local<Array> modules = env->module_load_list_array();
uint32_t l = modules->Length();
Expand Down Expand Up @@ -2436,7 +2435,7 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
char errmsg[1024];
snprintf(errmsg,
sizeof(errmsg),
"No such module: %s",
STR_NO_SUCH_MODULE,
*module_v);
return env->ThrowError(errmsg);
}
Expand All @@ -2462,7 +2461,7 @@ static void LinkedBinding(const FunctionCallbackInfo<Value>& args) {
char errmsg[1024];
snprintf(errmsg,
sizeof(errmsg),
"No such module was linked: %s",
STR_NO_SUCH_MODULE_LINKED,
*module_v);
return env->ThrowError(errmsg);
}
Expand Down Expand Up @@ -3268,7 +3267,7 @@ static bool ParseDebugOpt(const char* arg) {
if (port != nullptr) {
debug_port = atoi(port);
if (debug_port < 1024 || debug_port > 65535) {
fprintf(stderr, "Debug port must be in range 1024 to 65535.\n");
fprintf(stderr, STR_DEBUGPORT_OUTOFRANGE);
PrintHelp();
exit(12);
}
Expand All @@ -3278,57 +3277,7 @@ static bool ParseDebugOpt(const char* arg) {
}

static void PrintHelp() {
printf("Usage: node [options] [ -e script | script.js ] [arguments] \n"
" node debug script.js [arguments] \n"
"\n"
"Options:\n"
" -v, --version print Node.js version\n"
" -e, --eval script evaluate script\n"
" -p, --print evaluate script and print result\n"
" -c, --check syntax check script without executing\n"
" -i, --interactive always enter the REPL even if stdin\n"
" does not appear to be a terminal\n"
" -r, --require module to preload (option can be repeated)\n"
" --no-deprecation silence deprecation warnings\n"
" --throw-deprecation throw an exception anytime a deprecated "
"function is used\n"
" --trace-deprecation show stack traces on deprecations\n"
" --trace-sync-io show stack trace when use of sync IO\n"
" is detected after the first tick\n"
" --track-heap-objects track heap object allocations for heap "
"snapshots\n"
" --prof-process process v8 profiler output generated\n"
" using --prof\n"
" --v8-options print v8 command line options\n"
#if HAVE_OPENSSL
" --tls-cipher-list=val use an alternative default TLS cipher list\n"
#endif
#if defined(NODE_HAVE_I18N_SUPPORT)
" --icu-data-dir=dir set ICU data load path to dir\n"
" (overrides NODE_ICU_DATA)\n"
#if !defined(NODE_HAVE_SMALL_ICU)
" note: linked-in ICU data is\n"
" present.\n"
#endif
#endif
"\n"
"Environment variables:\n"
#ifdef _WIN32
"NODE_PATH ';'-separated list of directories\n"
#else
"NODE_PATH ':'-separated list of directories\n"
#endif
" prefixed to the module search path.\n"
"NODE_DISABLE_COLORS set to 1 to disable colors in the REPL\n"
#if defined(NODE_HAVE_I18N_SUPPORT)
"NODE_ICU_DATA data path for ICU (Intl object) data\n"
#if !defined(NODE_HAVE_SMALL_ICU)
" (will extend linked-in data)\n"
#endif
#endif
"NODE_REPL_HISTORY path to the persistent REPL history file\n"
"\n"
"Documentation can be found at https://nodejs.org/\n");
printf(STR_NODEHELP);
}


Expand Down Expand Up @@ -3396,7 +3345,7 @@ static void ParseArgs(int* argc,
args_consumed += 1;
eval_string = argv[index + 1];
if (eval_string == nullptr) {
fprintf(stderr, "%s: %s requires an argument\n", argv[0], arg);
fprintf(stderr, STR_REQUIRES_ARGUMENT, argv[0], arg);
exit(9);
}
} else if ((index + 1 < nargs) &&
Expand All @@ -3413,7 +3362,7 @@ static void ParseArgs(int* argc,
strcmp(arg, "-r") == 0) {
const char* module = argv[index + 1];
if (module == nullptr) {
fprintf(stderr, "%s: %s requires an argument\n", argv[0], arg);
fprintf(stderr, STR_REQUIRES_ARGUMENT, argv[0], arg);
exit(9);
}
args_consumed += 1;
Expand Down Expand Up @@ -3504,7 +3453,7 @@ static void StartDebug(Environment* env, bool wait) {
DispatchMessagesDebugAgentCallback);
debugger_running = env->debugger_agent()->Start(debug_port, wait);
if (debugger_running == false) {
fprintf(stderr, "Starting debugger on port %d failed\n", debug_port);
fprintf(stderr, STR_START_DEBUGGER_FAIL, debug_port);
fflush(stderr);
return;
}
Expand Down Expand Up @@ -3553,7 +3502,7 @@ static void DispatchDebugMessagesAsyncCallback(uv_async_t* handle) {
} while (isolate == nullptr);

if (debugger_running == false) {
fprintf(stderr, "Starting debugger agent.\n");
fprintf(stderr, STR_START_DEBUGGER_AGENT);

HandleScope scope(isolate);
Environment* env = Environment::GetCurrent(isolate);
Expand Down Expand Up @@ -3914,7 +3863,7 @@ void Init(int* argc,

// Anything that's still in v8_argv is not a V8 or a node option.
for (int i = 1; i < v8_argc; i++) {
fprintf(stderr, "%s: bad option: %s\n", argv[0], v8_argv[i]);
fprintf(stderr, "%s: " STR_BAD_OPTION ": %s\n", argv[0], v8_argv[i]);
}
delete[] v8_argv;
v8_argv = nullptr;
Expand Down
Loading