Class LanguageApp
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
भाषाऐप्लिकेशन
भाषा सेवा, स्क्रिप्ट को टेक्स्ट के अपने-आप होने वाले अनुवाद का हिसाब लगाने का तरीका देती है.
// The code below will write "Esta es una prueba" to the log.
const spanish = LanguageApp.translate('This is a test', 'en', 'es');
Logger.log(spanish);
ज़्यादा जानकारी वाला दस्तावेज़
translate(text, sourceLanguage, targetLanguage)
किसी टेक्स्ट को सोर्स भाषा से डेस्टिनेशन भाषा में अपने-आप अनुवाद करता है.
// The code below will write "Esta es una prueba" to the log.
const spanish = LanguageApp.translate('This is a test', 'en', 'es');
Logger.log(spanish);
भाषा के कोड की सूची
यहां उपलब्ध है.
पैरामीटर
नाम | टाइप | ब्यौरा |
text | String | वह टेक्स्ट जिसका अनुवाद करना है |
sourceLanguage | String | वह भाषा जिसका कोड लिखा गया है. अगर इसे खाली स्ट्रिंग पर सेट किया गया है, तो सोर्स भाषा का कोड अपने-आप पता चल जाएगा |
targetLanguage | String | वह भाषा कोड जिसमें टेक्स्ट का अनुवाद किया जाना है |
वापसी का टिकट
String
— अनुवाद किया गया टेक्स्ट
translate(text, sourceLanguage, targetLanguage, advancedArgs)
किसी टेक्स्ट को सोर्स भाषा से डेस्टिनेशन भाषा में अपने-आप अनुवाद करता है.
// The code below will write "Esta es una <strong>prueba</strong>" to the log.
const spanish = LanguageApp.translate(
'This is a <strong>test</strong>',
'en',
'es',
{contentType: 'html'},
);
Logger.log(spanish);
भाषा के कोड की सूची
यहां उपलब्ध है.
पैरामीटर
नाम | टाइप | ब्यौरा |
text | String | वह टेक्स्ट जिसका अनुवाद करना है |
sourceLanguage | String | वह भाषा जिसका कोड लिखा गया है. अगर इसे खाली स्ट्रिंग पर सेट किया गया है, तो सोर्स भाषा का कोड अपने-आप पता चल जाएगा |
targetLanguage | String | वह भाषा कोड जिसमें टेक्स्ट का अनुवाद किया जाना है |
advancedArgs | Object | JavaScript ऑब्जेक्ट के वैकल्पिक फ़ील्ड |
उन्नत पैरामीटर
नाम | टाइप | ब्यौरा |
contentType | String | टेक्स्ट का कॉन्टेंट टाइप; इसके लिए ये वैल्यू इस्तेमाल की जा सकती हैं: 'text' (डिफ़ॉल्ट) और 'html' |
वापसी का टिकट
String
— अनुवाद किया गया टेक्स्ट
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThe Language service automatically translates text between languages using the \u003ccode\u003etranslate()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify the source and target languages using language codes, with auto-detection available for the source language.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003etranslate()\u003c/code\u003e method supports optional advanced arguments for handling different content types like HTML.\u003c/p\u003e\n"],["\u003cp\u003eA comprehensive list of supported language codes can be found in the documentation.\u003c/p\u003e\n"]]],[],null,["# Class LanguageApp\n\nLanguageApp\n\nThe Language service provides scripts a way to compute automatic translations of text.\n\n```javascript\n// The code below will write \"Esta es una prueba\" to the log.\nconst spanish = LanguageApp.translate('This is a test', 'en', 'es');\nLogger.log(spanish);\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|----------------------------------------------------------------------------------------------------------|-------------|--------------------------------------------------------------------------------------|\n| [translate(text, sourceLanguage, targetLanguage)](#translate(String,String,String)) | `String` | Automatically translates some text from a source language to a destination language. |\n| [translate(text, sourceLanguage, targetLanguage, advancedArgs)](#translate(String,String,String,Object)) | `String` | Automatically translates some text from a source language to a destination language. |\n\nDetailed documentation\n----------------------\n\n### `translate(text, sourceLanguage, targetLanguage)`\n\nAutomatically translates some text from a source language to a destination language.\n\n```javascript\n// The code below will write \"Esta es una prueba\" to the log.\nconst spanish = LanguageApp.translate('This is a test', 'en', 'es');\nLogger.log(spanish);\n```\nA list of language codes is available [here](/translate/docs/languages).\n\n#### Parameters\n\n| Name | Type | Description |\n|--------------------|----------|------------------------------------------------------------------------------------------------------------------------------|\n| `text` | `String` | the text to translate |\n| `source``Language` | `String` | the language code in which text is written. If it is set to the empty string, the source language code will be auto-detected |\n| `target``Language` | `String` | the language code to which the text should be translated |\n\n#### Return\n\n\n`String` --- the translated text\n\n*** ** * ** ***\n\n### `translate(text, sourceLanguage, targetLanguage, advancedArgs)`\n\nAutomatically translates some text from a source language to a destination language.\n\n```javascript\n// The code below will write \"Esta es una \u003cstrong\u003eprueba\u003c/strong\u003e\" to the log.\nconst spanish = LanguageApp.translate(\n 'This is a <strong>test</strong>',\n 'en',\n 'es',\n {contentType: 'html'},\n);\nLogger.log(spanish);\n```\nA list of language codes is available [here](/translate/docs/languages).\n\n#### Parameters\n\n| Name | Type | Description |\n|--------------------|----------|------------------------------------------------------------------------------------------------------------------------------|\n| `text` | `String` | the text to translate |\n| `source``Language` | `String` | the language code in which text is written. If it is set to the empty string, the source language code will be auto-detected |\n| `target``Language` | `String` | the language code to which the text should be translated |\n| `advanced``Args` | `Object` | optional JavaScript object fields |\n\n#### Advanced parameters\n\n| Name | Type | Description |\n|-----------------|----------|--------------------------------------------------------------------------------|\n| `content``Type` | `String` | the content type of the text; supported values are 'text' (default) and 'html' |\n\n#### Return\n\n\n`String` --- the translated text"]]