Programmatically interact with Locadapt using the window.locadapt object
Locadapt exposes a 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.
window.locadapt.updateContent();
Use this method if Locadapt isn’t picking up on new content / the first page render. For example, if you have dynamically updated text nodes, you may want to call this (our 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.
This method is automatically called by Locadapt when the language is changed. You could rewrite this method to change the canonical and alternate links in a custom way, or to add additional functionality.
toggleSelector()
Toggles the visibility of the language selector dropdown.
window.locadapt.toggleSelector();
Useful for creating custom language selection interfaces.
selectLanguage(code: string, nativeName: string)
Programmatically changes the current language.
window.locadapt.selectLanguage('fr', 'Français');
Use this to switch languages without user interaction with the default selector.
Properties
currentTranslateToLanguage
Gets or sets the current target language for translations.
Provides access to the current Locadapt configuration and translation data.
const config = window.locadapt.localStorageData;
This object contains information about the project settings, available languages, and cached translations. It is a subset of the data stored on Locadapt’s servers, and a mirror of the data present in the actual 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:
Refer to the 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.
{"docsConfig":{"$schema":"https://mintlify.com/docs.json","theme":"mint","name":"Locadapt","colors":{"primary":"#0D9373","light":"#07C983","dark":"#0D9373"},"favicon":"/favicon.svg","logo":{"light":"https://mintcdn.com/locadapt/5bvMY6V7iWgT3zH2/logo/dark-text.svg?fit=max\u0026auto=format\u0026n=5bvMY6V7iWgT3zH2\u0026q=85\u0026s=e079d9e2c08e2b417fb4430a2cb604f4","dark":"https://mintcdn.com/locadapt/5bvMY6V7iWgT3zH2/logo/light-text.svg?fit=max\u0026auto=format\u0026n=5bvMY6V7iWgT3zH2\u0026q=85\u0026s=1cb05b7e196dfda41118cd86a0cd0520"},"navbar":{"links":[{"label":"Support","href":"mailto:support@locadapt.com"}],"primary":{"type":"button","label":"Website","href":"https://locadapt.com"}},"footer":{"socials":{"x":"https://x.com/simon_ilincev","github":"https://github.com/Destaq","linkedin":"https://www.linkedin.com/in/simon-ilincev"}},"integrations":{"ga4":{"measurementId":"G-9CJGZ61JMW"}},"navigation":{"global":{"anchors":[{"anchor":"Blog","href":"https://locadapt.com/blog","icon":"newspaper"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"locadapt","hasAudioNarration":false,"actualSubdomain":"locadapt","customDomains":["docs.locadapt.com"],"gitSource":{"type":"github","owner":"destaq","repo":"locadapt","deployBranch":"main","contentDirectory":"docs","isPrivate":false,"mountPath":"","label":""},"entitlements":{},"buildId":"6ae920ff66c39cbdc5f2c7e1:success","clientVersion":"0.0.4160","searchFilterCounts":[{"language":"default","tag":"Documentation","count":17},{"language":"default","tag":"Details","count":8},{"language":"default","tag":"Plugins","count":6},{"language":"default","tag":"Get Started","count":3}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"details/api-reference","slug":"/details/api-reference","pageMetadata":{"title":"API Reference","description":"Programmatically interact with Locadapt using the `window.locadapt` object","icon":"wrench","href":"/details/api-reference"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx, jsxs: _jsxs} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n code: \"code\",\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsxs(_components.p, {\n children: [\"Programmatically interact with Locadapt using the \", _jsx(_components.code, {\n children: \"window.locadapt\"\n }), \" object\"]\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,em:`em`,li:`li`,p:`p`,pre:`pre`,span:`span`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Locadapt exposes a `,_jsx(_components.code,{children:`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.`]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Locadapt is optimized to work out-of-the box, and only call or rewrite these methods when necessary for advanced or bespoke functionality.`})}),`\n`,_jsx(Heading,{level:`2`,id:`main-methods`,children:`Main Methods`}),`\n`,_jsx(Heading,{level:`3`,id:`updatecontent`,children:_jsx(_components.code,{children:`updateContent()`})}),`\n`,_jsx(_components.p,{children:`Manually triggers a content update, translating any new or changed content on the page.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`locadapt`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`updateContent`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Use this method if Locadapt isn’t picking up on new content / the first page render. For example, if you have dynamically updated `,_jsx(_components.em,{children:`text nodes`}),`, you may want to call this (our `,_jsx(_components.code,{children:`mutationObserver`}),` picks up on added nodes, but not text updates by default as for most scenarios this leads to excessive translation requests).`]}),`\n`,_jsx(Heading,{level:`3`,id:`figureoutlanguage`,children:_jsx(_components.code,{children:`figureOutLanguage()`})}),`\n`,_jsx(_components.p,{children:`Detects the current language based on the URL structure.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` languageInfo`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`locadapt`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`figureOutLanguage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Returns an array with the language name and its mapping information, or null if not detected.`}),`\n`,_jsx(Heading,{level:`3`,id:`setupcanonicalandalternatelinks`,children:_jsx(_components.code,{children:`setupCanonicalAndAlternateLinks()`})}),`\n`,_jsx(_components.p,{children:`Updates the canonical and alternate links in the document’s head to reflect the current language and available translations.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`locadapt`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`setupCanonicalAndAlternateLinks`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`This method is automatically called by Locadapt when the language is changed. You could rewrite this method to change the canonical and alternate links in a custom way, or to add additional functionality.`}),`\n`,_jsx(Heading,{level:`3`,id:`toggleselector`,children:_jsx(_components.code,{children:`toggleSelector()`})}),`\n`,_jsx(_components.p,{children:`Toggles the visibility of the language selector dropdown.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`locadapt`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`toggleSelector`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Useful for creating custom language selection interfaces.`}),`\n`,_jsx(Heading,{level:`3`,id:`selectlanguage-code-string-nativename-string`,children:_jsx(_components.code,{children:`selectLanguage(code: string, nativeName: string)`})}),`\n`,_jsx(_components.p,{children:`Programmatically changes the current language.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`locadapt`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`selectLanguage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'fr'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'Français'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Use this to switch languages without user interaction with the default selector.`}),`\n`,_jsx(Heading,{level:`2`,id:`properties`,children:`Properties`}),`\n`,_jsx(Heading,{level:`3`,id:`currenttranslatetolanguage`,children:_jsx(_components.code,{children:`currentTranslateToLanguage`})}),`\n`,_jsx(_components.p,{children:`Gets or sets the current target language for translations.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`locadapt`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`currentTranslateToLanguage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`locadapt`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`currentTranslateToLanguage`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Español'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`localstoragedata`,children:_jsx(_components.code,{children:`localStorageData`})}),`\n`,_jsx(_components.p,{children:`Provides access to the current Locadapt configuration and translation data.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` config`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`locadapt`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`localStorageData`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`This object contains information about the project settings, available languages, and cached translations. It is a subset of the data stored on Locadapt’s servers, and a mirror of the data present in the actual `,_jsx(_components.code,{children:`localStorage`}),` of your site by our plugin.`]}),`\n`,_jsx(Heading,{level:`2`,id:`advanced-usage`,children:`Advanced Usage`}),`\n`,_jsx(_components.p,{children:`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:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:_jsx(_components.code,{children:`applyTranslations(translations: Map\u003cstring, { originalText: string; translatedText: string; }>)`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.code,{children:`collectTranslatableContent()`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.code,{children:`sendTranslationRequest(items: TranslationItem[])`})}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Refer to the `,_jsx(_components.code,{children:`window.locadapt`}),` object or `,_jsx(`a`,{href:`mailto:support@locadapt.com`,target:`_blank`,children:`contact us`}),` for detailed information on these advanced methods.`]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Modifying internal Locadapt functionality may lead to unexpected behavior. Always test thoroughly when using these advanced methods.`})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"API Reference","description":"Programmatically interact with Locadapt using the `window.locadapt` object","icon":"wrench","href":"/details/api-reference"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Main Methods","slug":"main-methods","depth":2,"children":[{"title":"updateContent()","slug":"updatecontent","depth":3,"children":[]},{"title":"figureOutLanguage()","slug":"figureoutlanguage","depth":3,"children":[]},{"title":"setupCanonicalAndAlternateLinks()","slug":"setupcanonicalandalternatelinks","depth":3,"children":[]},{"title":"toggleSelector()","slug":"toggleselector","depth":3,"children":[]},{"title":"selectLanguage(code: string, nativeName: string)","slug":"selectlanguage-code-string-nativename-string","depth":3,"children":[]}]},{"title":"Properties","slug":"properties","depth":2,"children":[{"title":"currentTranslateToLanguage","slug":"currenttranslatetolanguage","depth":3,"children":[]},{"title":"localStorageData","slug":"localstoragedata","depth":3,"children":[]}]},{"title":"Advanced Usage","slug":"advanced-usage","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"locadapt","siteName":"Locadapt","title":"API Reference - Locadapt","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-01-07T02:46:39.334Z","originalFileLocation":"details/api-reference.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Programmatically interact with Locadapt using the window.locadapt object\">\u003cmeta data-mint-head name=\"application-name\" content=\"Locadapt\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/locadapt/oJxB6zIkGMZRcuJ6/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/locadapt/oJxB6zIkGMZRcuJ6/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/locadapt/oJxB6zIkGMZRcuJ6/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/locadapt/oJxB6zIkGMZRcuJ6/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/locadapt/oJxB6zIkGMZRcuJ6/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/locadapt/oJxB6zIkGMZRcuJ6/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/locadapt/oJxB6zIkGMZRcuJ6/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/locadapt/oJxB6zIkGMZRcuJ6/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/locadapt/oJxB6zIkGMZRcuJ6/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"API Reference - Locadapt\">\u003cmeta data-mint-head property=\"og:description\" content=\"Programmatically interact with Locadapt using the window.locadapt object\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Locadapt\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.locadapt.com/details/api-reference\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://locadapt.mintlify.site/_mintlify/api/og/v2?division=Details\u0026amp;title=API+Reference\u0026amp;description=Programmatically+interact+with+Locadapt+using+the+%60window.locadapt%60+object\u0026amp;theme=8e8695ab0534f88e1ff4f0e8\u0026amp;signature=815b635bc7047a467c7abcc764c4a438a9e26d2a68ce51d9b099ac56dffe5e47\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"API Reference - Locadapt\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Programmatically interact with Locadapt using the window.locadapt object\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://locadapt.mintlify.site/_mintlify/api/og/v2?division=Details\u0026amp;title=API+Reference\u0026amp;description=Programmatically+interact+with+Locadapt+using+the+%60window.locadapt%60+object\u0026amp;theme=8e8695ab0534f88e1ff4f0e8\u0026amp;signature=815b635bc7047a467c7abcc764c4a438a9e26d2a68ce51d9b099ac56dffe5e47\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/locadapt/oJxB6zIkGMZRcuJ6/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Locadapt\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#0D9373\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.locadapt.com/details/api-reference\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/details/api-reference.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.locadapt.com/#organization\",\"name\":\"Locadapt\",\"url\":\"https://docs.locadapt.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/locadapt/5bvMY6V7iWgT3zH2/logo/dark-text.svg?fit=max\u0026auto=format\u0026n=5bvMY6V7iWgT3zH2\u0026q=85\u0026s=e079d9e2c08e2b417fb4430a2cb604f4\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.locadapt.com#website\",\"name\":\"Locadapt\",\"url\":\"https://docs.locadapt.com\",\"publisher\":{\"@id\":\"https://docs.locadapt.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.locadapt.com/details/api-reference#webpage\",\"url\":\"https://docs.locadapt.com/details/api-reference\",\"name\":\"API Reference\",\"description\":\"Programmatically interact with Locadapt using the window.locadapt object\",\"dateModified\":\"2026-01-07T02:46:39.334Z\",\"isPartOf\":{\"@id\":\"https://docs.locadapt.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.locadapt.com/details/api-reference#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.locadapt.com/details/api-reference#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Details\",\"item\":\"https://docs.locadapt.com/details/translation-engine\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"API Reference\",\"item\":\"https://docs.locadapt.com/details/api-reference\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.locadapt.com/details/api-reference#article\",\"headline\":\"API Reference\",\"name\":\"API Reference\",\"description\":\"Programmatically interact with Locadapt using the window.locadapt object\",\"url\":\"https://docs.locadapt.com/details/api-reference\",\"mainEntityOfPage\":{\"@id\":\"https://docs.locadapt.com/details/api-reference#webpage\"},\"dateModified\":\"2026-01-07T02:46:39.334Z\",\"publisher\":{\"@id\":\"https://docs.locadapt.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.locadapt.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Locadapt\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Locadapt\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/details/api-reference.md","siteName":"Locadapt","nav":{"global":{"anchors":[{"anchor":"Blog","href":"https://locadapt.com/blog","icon":"newspaper"}]},"anchors":[{"anchor":"Documentation","icon":"book-open","groups":[{"group":"Get Started","pages":[{"title":"Introduction","icon":"language","href":"/introduction"},{"title":"Quickstart","icon":"rocket","href":"/quickstart"},{"title":"FAQ","icon":"comments","href":"/faq"}]},{"group":"Details","pages":[{"title":"Translation Engine","icon":"robot","href":"/details/translation-engine"},{"title":"Quota Usage","icon":"chart-bar","href":"/details/quota-usage"},{"title":"URL Setup","icon":"link","href":"/details/url-setup"},{"title":"Advanced Configuration","icon":"gear","href":"/details/advanced-configuration"},{"title":"Local Development","icon":"code","href":"/details/local-development"},{"title":"Custom Styling","icon":"paintbrush","href":"/details/custom-styling"},{"title":"Translation Prevention","description":"Learn how to prevent specific elements from being translated on your site","icon":"octagon-exclamation","href":"/details/translation-prevention"},{"title":"API Reference","icon":"wrench","href":"/details/api-reference"}]},{"group":"Plugins","pages":[{"title":"WordPress","description":"Learn how to set up Locadapt on your WordPress site","icon":"wordpress","href":"/plugins/wordpress"},{"title":"Wix","icon":"wix","href":"/plugins/wix"},{"title":"Shopify","icon":"shopify","href":"/plugins/shopify"},{"title":"Squarespace","icon":"squarespace","href":"/plugins/squarespace"},{"title":"Frontend Frameworks","icon":"react","href":"/plugins/frontend-frameworks"},{"title":"Other Platforms","icon":"globe","href":"/plugins/others"}]}]}]},"basePath":"","title":"API Reference - Locadapt","buildId":"dpl_GRSyrvXT6FFTpZZTGz5iZPp3D2zE","deploymentId":"dpl_GRSyrvXT6FFTpZZTGz5iZPp3D2zE","dynamics":[],"chunks":[]}