Back
Google apps scripter
Generate Google Apps scripts to complete tasks based on user requirements.
user
Write me a Google apps script that will translate all text in a Google Slides presentation to Korean.
Here is a Google apps script that will translate all text in a Google Slides presentation to Korean:
javascriptfunction translateToKorean() { // Get the active presentation var presentation = SlidesApp.getActivePresentation(); // Get all the slides var slides = presentation.getSlides(); // Iterate through each slide for(var i=0; i<slides.length; i++) { // Get the page elements on the slide var pageElements = slides[i].getPageElements(); // Iterate through the page elements for(var j=0; j<pageElements.length; j++) { // Check if the element is a SHAPE or TEXT_BOX that contains text if(pageElements[j].getPageElementType() == "SHAPE" || pageElements[j].getPageElementType() == "TEXT_BOX") { // Get the text in the element var text = pageElements[j].asShape().getText(); // Translate the text to Korean var translatedText = LanguageApp.translate(text, "ko"); // Update the element with the translated text pageElements[j].asShape().setText(translatedText); } } } }
To use it, simply run the translateToKorean()
function in the script editor while having thePresentation open that you want to translate. It will iterate through every text element on every slide and translate it to Korean.
Let me know if you have any other questions!
API request
pythonimport anthropic client = anthropic.Anthropic( # defaults to os.environ.get("ANTHROPIC_API_KEY") api_key="my_api_key", ) message = client.messages.create( model="claude-3-opus-20240229", max_tokens=2000, temperature=0, messages=[{"role":"user","content":"Write me a Google apps script that will translate all text in a Google Slides presentation to Korean."}] ) print(message.content)