Setting portal language based on URL
Supported languages
The ReturnZap returns portal supports translation into over a dozen languages, including:
- English (US and UK spelling)
- German
- French
- Spanish
- Italian
- Swedish
- Norwegian
- Polish
- More
By default, the returns portal will display in any supported language which is set as the end user's default browser language. For example, if the user has their browser set to German, the returns portal will automatically translate into German.
Modifying portal languages
The default translation behavior of the returns portal can be changed in one of two ways:
- Using the option to customize the returns portal in ReturnZap Settings > Portal > Tweak Portal. This can be used to force the portal into a fixed language option.
- Via the
language
parameter within the ReturnZap portal embed code
Using the language parameter in the portal embed code
Shops have the option to embed the ReturnZap returns portal by copying and pasting a few simple lines of javascript code into a Shopify page of their choosing:
The default code looks like this:
<script src="https://portal.returnzap.com/v2.js" async></script> <return-zap shop-id="SHOP-ID-HERE"></return-zap>
The portal can be modified by adding a language
parameter to the script:
<script src="https://portal.returnzap.com/v2.js" async></script> <return-zap shop-id="SHOP-ID-HERE" <u><b>language="de"</b></u>></return-zap>
Setting a custom language parameter based on URL structure
The language parameter in the portal embed code can be further modified using custom Javascript.
The exact structure will depend on your translated URL structures but most commonly can be set using the top level domain structure - for example .com or .co.uk - or the first path fragment of the URL - for example .com/en/ or .com/fr/.
This code example provides a basis for further customization:
<script src="https://portal.returnzap.com/v2.js" async></script> <return-zap shop-id="SHOP-ID-HERE"></return-zap> <script> const topLevelDomain = location.hostname.split('.').pop() const firstPathFragment = location.pathname.split('/')[1].toLocaleLowerCase() let language if (topLevelDomain === 'com' && firstPathFragment === 'de-at') language = 'de' else if (topLevelDomain === 'com' && firstPathFragment === 'en') language = 'en' else if (topLevelDomain === 'de') language = 'de' else if (topLevelDomain === 'es') language = 'es' if (language) document.querySelector('return-zap').setAttribute('language', language) </script>