translate-web
v1.0.0
Published
Auto translate entire website using Google Translate API with IP based language detection
Maintainers
Readme
translate-web
Auto translate your entire website using Google Translate API. Supports IP based language detection and manual language switching.
Install
npm install translate-web
Usage
import TranslateWeb from "translate-web";
TranslateWeb.init({
apiKey: "YOUR_GOOGLE_API_KEY",
autoDetect: true,
supportedLangs: ["en", "bn", "fr"],
});Features
- Auto IP-based language detection
- Manual language switching
- Local caching for performance
- Optimized DOM traversal
- Configurable ignore classes
API Reference
init(options)
Initialize the translator with configuration options.
Options:
apiKey(required): Google Translate API keydefaultLang(optional): Default language, defaults to "en"supportedLangs(optional): Array of supported languages, defaults to ["en"]autoDetect(optional): Enable IP-based detection, defaults to trueignoreClass(optional): CSS class to ignore elements, defaults to "no-translate"
switch(lang)
Manually switch to a different language.
Parameters:
lang: Language code to switch to
License
MIT || @ 2026 Ahteshamul Hasan
