Language Service
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
语言
借助此服务,脚本可以自动翻译文本。
// The code below will write 'Esta es una prueba' to the log.
var spanish = LanguageApp.translate('This is a test', 'en', 'es');
Logger.log(spanish);
类
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThe Language service enables automatic text translation within scripts.\u003c/p\u003e\n"],["\u003cp\u003eIt uses the \u003ccode\u003eLanguageApp\u003c/code\u003e class and methods like \u003ccode\u003etranslate()\u003c/code\u003e to perform the translations.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify the source and target languages for translation using language codes like 'en' for English and 'es' for Spanish.\u003c/p\u003e\n"]]],[],null,["# Language Service\n\nLanguage\n\nThis service allows scripts to automatically translate text. \n\n // The code below will write 'Esta es una prueba' to the log.\n var spanish = LanguageApp.translate('This is a test', 'en', 'es');\n Logger.log(spanish);\n\nClasses\n-------\n\n| Name | Brief description |\n|-------------------------------------------------------------|----------------------------------------------------------------------------------------|\n| [LanguageApp](/apps-script/reference/language/language-app) | The Language service provides scripts a way to compute automatic translations of text. |\n\n[LanguageApp](/apps-script/reference/language/language-app)\n-----------------------------------------------------------\n\n### Methods\n\n| Method | Return type | Brief description |\n|------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|--------------------------------------------------------------------------------------|\n| [translate(text, sourceLanguage, targetLanguage)](/apps-script/reference/language/language-app#translate(String,String,String)) | `String` | Automatically translates some text from a source language to a destination language. |\n| [translate(text, sourceLanguage, targetLanguage, advancedArgs)](/apps-script/reference/language/language-app#translate(String,String,String,Object)) | `String` | Automatically translates some text from a source language to a destination language. |"]]