简体   繁体   English

设置 NodeJs 错误的语言

[英]Set Language of NodeJs Errors

Is there a way to set what language node will output errors in?有没有办法设置哪个语言节点将输出错误? For example, if I wanted to use node as a Spanish user and my error was "Function not found", can node output "Función no encontrada" instead?例如,如果我想以西班牙语用户的身份使用 node 并且我的错误是“找不到函数”,那么 node 可以输出“Función no encontrada”吗?

As errors, exceptions, stacktraces, logs etc. are not user centric, it's not recommended to have them in other language than English.由于错误、异常、堆栈跟踪、日志等不是以用户为中心的,因此不建议使用除英语以外的其他语言。 It does not affect consumers at all and would limit developer staffing.它根本不会影响消费者,并且会限制开发人员的人员配备。

That said, you can catch the exception and give any message you desire.也就是说,您可以捕获异常并提供您想要的任何消息。 For example:例如:

try {
  throw new Error("El errore");
} catch (e) {
  e.message = "The horror"
  throw e;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM