Per creà un widget di Google Translate, avete bisognu di includà u script API di Google Translate in u vostru situ web è creà un cuntainer per u widget. Eccu i passi:
Ottene una Chjave API Google Translate: Per utilizà l'API Google Translate, avete bisognu di avè un contu Google Cloud è generà una chjave API.
Includite l'script API in u vostru HTML: aghjunghje u codice seguente à u vostru schedariu HTML per include l'API Google Translate.
Crea un containeru per u widget: Crea a
div
elementu cun un unicuid
chì servirà cum'è cuntainer per u widget. Pudete mette stu elementu in ogni locu in u vostru situ web induve vulete chì u widget apparisce.- Inizializza u widget: Aghjunghjite u seguente codice JavaScript à u vostru schedariu HTML per inizializà u widget è stabilisce a lingua predeterminata.
Pudete rimpiazzà'en'
cù u codice di lingua predeterminatu desideratu. - Pruvate u widget: Caricate u vostru situ web in un navigatore è verificate chì u widget funziona bè.
Nota: Stu codice assume chì avete accessu à l'API Google Translate, chì ùn hè micca dispunibule gratuitamente. Sè vo site custruendu un situ web per scopi cummerciale, pudete avè bisognu di pagà per l'usu di l'API.