File: google-apps-scripter.md | Updated: 11/15/2025
Agent Skills are now available! Learn more about extending Claude's capabilities with Agent Skills .
English
Search...
Ctrl K
Search...
Navigation
Prompt Library
Google apps scripter
Home Developer Guide API Reference Model Context Protocol (MCP) Resources Release Notes
On this page
Copy this prompt into our developer Console to try it for yourself!
| | Content | | --- | --- | | User | Write me a Google apps script that will translate all text in a Google Slides presentation to Korean. |
Here’s a Google Apps Script that translates all the text in a Google Slides presentation to Korean:
Copy
function translateSlidesToKorean() {
var presentation = SlidesApp.getActivePresentation();
var slides = presentation.getSlides();
for (var i = 0; i < slides.length; i++) {
var slide = slides[i];
var pageElements = slide.getPageElements();
for (var j = 0; j < pageElements.length; j++) {
var pageElement = pageElements[j];
if (pageElement.getPageElementType() === SlidesApp.PageElementType.SHAPE) {
var shape = pageElement.asShape();
if (shape.getText() !== null) {
var text = shape.getText().asString();
var translatedText = LanguageApp.translate(text, '', 'ko');
shape.getText().setText(translatedText);
}
} else if (pageElement.getPageElementType() === SlidesApp.PageElementType.TABLE) {
var table = pageElement.asTable();
var numRows = table.getNumRows();
var numColumns = table.getNumColumns();
for (var row = 0; row < numRows; row++) {
for (var col = 0; col < numColumns; col++) {
var tableCell = table.getCell(row, col);
var text = tableCell.getText().asString();
var translatedText = LanguageApp.translate(text, '', 'ko');
tableCell.getText().setText(translatedText);
}
}
}
}
}
}
Here’s how the script works:
translateSlidesToKorean() function retrieves the active Google Slides presentation using SlidesApp.getActivePresentation().getSlides() method.getPageElements() method.getPageElementType():
SlidesApp.PageElementType.SHAPE), we get the text content of the shape using getText().asString(). We then translate the text to Korean using LanguageApp.translate(text, '', 'ko'), where '' represents the source language (auto-detect) and 'ko' represents the target language (Korean). Finally, we set the translated text back to the shape using setText().SlidesApp.PageElementType.TABLE), we iterate over each cell in the table and translate the text within each cell similarly to how we handle shapes.Note: This script assumes that you have the necessary permissions to access and modify the Google Slides presentation. Make sure you have the required access rights before running the script.
Also, keep in mind that the translation is performed using the Google Translate API, so the quality of the translation may vary depending on the complexity of the text and the capabilities of the translation service.
Copy
import anthropic
client = anthropic.Anthropic(
# defaults to os.environ.get("ANTHROPIC_API_KEY")
api_key="my_api_key",
)
message = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=2000,
temperature=0,
messages=[\
{\
"role": "user",\
"content": [\
{\
"type": "text",\
"text": "Write me a Google apps script that will translate all text in a Google Slides presentation to Korean."\
}\
]\
}\
]
)
print(message.content)
Was this page helpful?
YesNo
Excel formula expert Python bug buster
Assistant
Responses are generated using AI and may contain mistakes.