מדריך למתחילים בנושא תוספים ל-Google Docs Editor
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
במדריך הזה ליצירת תוסף מהירה, יוצרים תוסף ל-Google Docs Editor שמתרגם טקסט שנבחר במסמך.
מטרות
- מגדירים את הסקריפט.
- מריצים את הסקריפט.
דרישות מוקדמות
כדי להשתמש בדוגמה הזו, צריך לעמוד בדרישות המוקדמות הבאות:
- חשבון Google (יכול להיות שחשבונות Google Workspace ידרשו אישור אדמין).
- דפדפן אינטרנט עם גישה לאינטרנט.
הגדרת הסקריפט
- יוצרים מסמך Google Docs בכתובת docs.new.
- לוחצים על תוספים > Apps Script.
- לוחצים על פרויקט ללא שם.
- משנים את השם של פרויקט Apps Script ל-Translate Docs ולוחצים על Rename (שינוי שם).
- לצד הקובץ
Code.gs
, לוחצים על סמל האפשרויות הנוספות more_vert
> שינוי שם. נותנים לקובץ את השם translate
.
- לוחצים על סמל הוספת קובץ add
> HTML. נותנים לקובץ את השם
sidebar
.
מחליפים את התוכן של כל קובץ בקוד המתאים הבא, ואז לוחצים על סמל השמירה
.
הפעלת הסקריפט
- במסמך Docs, טוענים מחדש את הדף.
- לוחצים על תוספים >
Translate Docs
> התחלה.
- כשמוצגת בקשה, מאשרים את התוסף.
אחרי האישור, התוסף יופעל מחדש.
- מקלידים טקסט במסמך ובוחרים אותו.
- בתוסף, לוחצים על Translate (תרגום). כדי להחליף את הטקסט במסמך, לוחצים על הוספה.
השלבים הבאים
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-31 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-31 (שעון UTC)."],[[["\u003cp\u003eThis quickstart guide demonstrates how to build a Google Docs add-on using Apps Script that translates selected text within a document.\u003c/p\u003e\n"],["\u003cp\u003eThe add-on allows users to select text, choose source and target languages, and obtain the translation, with an option to insert the translated text directly into the document.\u003c/p\u003e\n"],["\u003cp\u003eUsers need a Google Account and a web browser to utilize this add-on, which involves setting up a script, running it, and authorizing permissions.\u003c/p\u003e\n"],["\u003cp\u003eThe add-on provides a user interface within a sidebar in Google Docs for easy interaction and language selection.\u003c/p\u003e\n"],["\u003cp\u003eFurther resources are available for extending Google Docs functionality with Apps Script and exploring the Document service for more advanced customizations.\u003c/p\u003e\n"]]],["This document guides the creation of a Google Docs add-on for text translation. It involves creating a new Google Docs file and an Apps Script project. You will rename files to `translate` and `sidebar`, and replace their content with provided code. The code defines functions for opening a sidebar, selecting text, translating it, and inserting the translated text back into the document. After reloading, accessing the add-on requires selecting text, choosing languages, clicking 'Translate', and finally, clicking 'Insert'.\n"],null,[]]