The `vue-gtranslate` package provides a Vue.js component designed to integrate Google Translate's 'Website Translator' widget into a Vue application. It facilitates on-the-fly page translation, supporting approximately 40 languages, and allows for basic visual customization through CSS classes. As of version 2.0.20, the project is actively maintained but explicitly cautions users about potential instability and the expectation of bugs, suggesting a more community-driven or less rigorously tested release cycle. Its core differentiator lies in simplifying the embedding process of the Google Translate script and its associated UI within a Vue component, thereby abstracting some of the direct DOM manipulation typically required. This solution wraps Google's client-side translation widget and does not offer an offline or server-side translation mechanism.
npm install vue-gtranslateVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `vue-gtranslate` into a Vue 3 application. It includes the necessary external Google Translate script setup in `index.html` and shows how to import and use the `Translator` component along with its crucial CSS for proper functionality and UI control.
Add `import 'vue-gtranslate/translator.css';` to your main Vue component or global stylesheet entry point.
Be prepared to implement custom CSS overrides or JavaScript workarounds for common issues. Monitor the package's GitHub issues for known problems and community solutions. Consider testing thoroughly in production-like environments.
Ensure the `<script>` tags for `element.js` and the `googleTranslateElementInit` function are correctly placed in your `index.html` `<head>` or `<body>` section as demonstrated in the quickstart, and that the `google_translate_element` div exists in the DOM.
Verify network connectivity, ensure no browser extensions are blocking the Google script, and confirm the `element.js` script and `googleTranslateElementInit` function are correctly embedded in your `index.html` file and loaded before your Vue application attempts to use `vue-gtranslate`.
Ensure the `div` with the ID specified in `new google.translate.TranslateElement()` is present in your `index.html`. If you are manually controlling the widget's visibility, ensure your CSS or component logic correctly displays it. The `vue-gtranslate` component typically handles rendering it within its own template.
No dependency data recorded yet.