window.locadapt
object that allows developers to programmatically interact with the translation functionality. This API reference outlines the main methods and properties available for advanced usage and integration.
Locadapt is optimized to work out-of-the box, and only call or rewrite these methods when necessary for advanced or bespoke functionality.
Main Methods
updateContent()
Manually triggers a content update, translating any new or changed content on the page.
mutationObserver
picks up on added nodes, but not text updates by default as for most scenarios this leads to excessive translation requests).
figureOutLanguage()
Detects the current language based on the URL structure.
setupCanonicalAndAlternateLinks()
Updates the canonical and alternate links in the document’s head to reflect the current language and available translations.
toggleSelector()
Toggles the visibility of the language selector dropdown.
selectLanguage(code: string, nativeName: string)
Programmatically changes the current language.
Properties
currentTranslateToLanguage
Gets or sets the current target language for translations.
localStorageData
Provides access to the current Locadapt configuration and translation data.
localStorage
of your site by our plugin.
Advanced Usage
For more complex integrations or custom behavior, you can also access and modify internal Locadapt properties and methods. However, use these with caution as they may affect the core functionality:applyTranslations(translations: Map<string, { originalText: string; translatedText: string; }>)
collectTranslatableContent()
sendTranslationRequest(items: TranslationItem[])
window.locadapt
object or contact us for detailed information on these advanced methods.
Modifying internal Locadapt functionality may lead to unexpected behavior. Always test thoroughly when using these advanced methods.