Other integration - How to change the position of the language switcher?
In this article, you'll learn how to change the position of the Weglot language switcher if you are using a different integration than WordPress and Shopify.
1. Use the Switcher Editor feature
The switcher editor allows you to move the language switcher in context on your website by dragging and dropping the button on a preview of your website.
To use it, you can follow this article: How to use the Switcher Editor?
⚠️ Note that your website must be live and accessible in order to be able to use the Switcher Editor
2. The language link hooks
You have the possibility to create language elements into your native menu, for example, and link them with the translation hooks according to this guide
For instance, you create a "Languages" item menu with "English" and "French" as sub-menus.
English will have the link #Weglot-en
, and French will have the link #Weglot-fr
Note that the capital letter on the ' W' is important
If you have any trouble finding the correct short code, you can type your language here and use the related short code: https://weglot.com/documentation/available-languages/
3. The Weglot_here option
You can paste the code below into your source code at the place you want the language switcher to be displayed:
<div id="weglot_here"></div>
4. The switcher option
You can also integrate the switcher manually to any elements present in your website by adding the switchers
option to your Weglot.initialize
code
To do that, go to the page where is located your Weglot code snippet You should see the following code (with your own API key in replace of "YOUR_API_KEY"):
<!--Start Weglot Script--> <script src=“//cdn.weglot.com/weglot.min.js”></script> <script id=“has-script-tags”>Weglot.initialize({ api_key:“YOUR_API_KEY” })</script> <!--End Weglot Script-->
, switchers: [ { button_style: { full_name: true, with_name: true, is_dropdown: true, with_flags: true, flag_type: "circle" }, location: { target: ".header-nav", // You'll probably have to change it (see the step below in order to find the correct CSS selector) sibling: null } } ] }); </script>
Important: don’t forget the comma after your API key.
The piece of code that’s important here is the .header-nav
, as this determines the location of your language switcher. This needs to be replaced with the CSS selector of the parent element where you want the language switcher to be placed.
⚠️ To find the CSS selector (the "target"):
- Right-click on the element you want to place the language switcher into.
- Go to "Inspect"
- Use the arrow on the top left of the console.
- Right-click on the element in the console.
- Copy > Copy selector
- Paste the code target field between the double quotes
So, for example, if you want to add it to your menu:
<nav class="menu">
target: "nav.menu",
You can find more information about this method in our Developer Documentation
5. Additional information (Webflow and Squarespace)
If you are using Squarespace, the language switcher here is managed by Squarespace directly, so we recommend following their documentation.
If you are using Webflow, don't hesitate to try this guide. It will allow you to create nice-looking language switchers for your website.