Szybki start z dodatkiem do Edytora Dokumentów Google
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
W tym krótkim wprowadzeniu utworzysz dodatek do edytora Dokumentów Google, który tłumaczy zaznaczony tekst w dokumencie.
Cele
- Skonfiguruj skrypt.
- Uruchom skrypt.
Wymagania wstępne
Aby użyć tego przykładu, musisz spełnić te wymagania wstępne:
- Konto Google (w przypadku kont Google Workspace może być wymagana zgoda administratora).
- przeglądarkę internetową z dostępem do internetu,
Konfigurowanie skryptu
- Utwórz dokument Google na stronie docs.new.
- Kliknij Rozszerzenia > Apps Script.
- Kliknij Projekt bez nazwy.
- Zmień nazwę projektu Apps Script na Translate Docs i kliknij Zmień nazwę.
- Obok pliku
Code.gs
kliknij Więcej more_vert
> Zmień nazwę. Nadaj plikowi nazwę translate
.
- Kliknij Dodaj plik add
> HTML. Nadaj plikowi nazwę
sidebar
.
Zastąp zawartość każdego pliku odpowiednim kodem, a następnie kliknij Zapisz
.
Uruchamianie skryptu
- W dokumencie w Dokumentach ponownie załaduj stronę.
- Kliknij Rozszerzenia >
Przetłumacz dokumenty
> Rozpocznij.
- Gdy pojawi się odpowiedni komunikat, autoryzuj dodatek.
Po autoryzacji dodatek zostanie ponownie uruchomiony.
- Wpisz tekst w dokumencie i zaznacz go.
- W dodatku kliknij Tłumacz. Aby zastąpić tekst w dokumencie, kliknij Wstaw.
Dalsze kroki
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-31 UTC.
[null,null,["Ostatnia aktualizacja: 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,[]]