LogoLogo
MerchantsHelpSign in
  • Overview
    • Countries & Currencies
    • Glopal Solutions Portfolio
  • Getting started
    • Shopify
      • Glopal Duty & Tax for Shopify
      • Shopify Collaborator Access
    • BigCommerce
    • Magento (Adobe Commerce)
      • Magento 1
      • Magento 2
        • Magento Activation
        • Magento Configuration
        • Magento Database Model
    • Visualsoft
    • PrestaShop
  • Marketing Solutions
    • Acquisition channels
      • Integrate Google Ads
      • Integrate Facebook Ads
    • Feed localization
      • Read domestic items
      • Localize the items
      • Upload the localized items
    • Features / Customization
      • Google Shopping countries coverage
      • Filters
      • Free listings
      • Comparison Shopping Services (CSS)
    • Google Ads
      • Conversion tracking
      • Standard accounts structure
      • Launching and monitoring Google Ads campaigns
    • Facebook
      • Facebook & Instagram Shops
      • Catalog Based Campaigns
      • Conversion and Brand awareness campaigns
      • Facebook conversion tracking
    • Email marketing
  • Localization
    • Site localization
      • Content localization
      • Price localization
      • Site search
      • Checkout
      • User account
    • Site discovery
      • Domains and Routing
      • Search engine optimization
      • Geo-localization
      • Country selector
    • Content distribution
      • Site security
      • Domains (DNS)
      • Traffic Splitting
        • Akamai
        • Cloudflare
        • Nginx
        • Microsoft IIS
        • AWS CloudFront
        • Magento Cloud
      • Third-party CDN
        • Cloudflare
      • Site speed
    • Integrations
      • CSS customizations
      • JavaScript customizations
      • Server-side customizations
      • Exclude from localization
      • Integration examples
        • Hiding Products
        • Newsletter Signup
        • Custom Price Logic
  • Checkout
    • Localized checkout
      • Overview
      • Styling
      • Integration
        • Callback Functions
        • Confirmation Page
        • Checkout Analytics
        • Allowlisting Glopal IPs
      • Price localization
    • Order processing
      • Order creation
        • Plug & Play integration
        • Order API
        • Event webhook
        • Custom Integration
      • Cancellation & refund
      • Returns
      • Buyer's communication
      • Customer account
    • Financials
      • EU VAT
  • DUTY & TAXES
    • Product Classification
    • Duty & Tax Calculation
      • Product Pricing
      • Supported Countries
    • Compliance Checks
      • Prohibited Goods
      • Denied Party Screening
  • SHIPPING
    • Order Creation
    • Label Generation
    • Manifest
    • Tracking
  • Translations
    • Translation Editor
  • MERCHANT ACCOUNT
    • Dashboards
      • SEO dashboard
  • What's New
    • Release Notes
Powered by GitBook
On this page
  • Configuration
  • Content localization
  • Link rewrite
  • Translations
  1. Localization
  2. Integrations

JavaScript customizations

Each localized page has access to JavaScript global object window.glopalYou can use it to determine if code is running on original or localized page:

if (window.glopal !== undefined) {
    /* Remove newsletter popup on localized pages */
    $.fancybox && $.fancybox.close(true)
}

Configuration

Inside window.glopal.config.target property you can find useful data about language and currency and localized page:

{
    "countryCode": "PL",
    "languageTag": "pl-PL",
    "currencyCode": "PLN",
    "currencySymbol": "zł"
}

You can use them for dynamic customizations:

if (window.glopal !== undefined) {
  /* load additional font for greek language */
  (function() {
   a if (!glopal.config.target.languageTag.startsWith('el-')) {
      return;
    }
  
    const n = document.createElement('style');
    n.textContent = "@font-face {font-family:Interstate; src:local(serif);}";
    document.head.appendChild(n);
  })();
}

Content localization

Glopal will automatically localize all visible content and links, even if it is updated dynamically after the initial page load.

Even that in general you don't need customizations to get localization of your website, in some specific cases it may be useful to have additional control. For example there could be analytics code that is not visible or elements of the UI that should be sorted where translating dynamic content before it is rendered can be useful. Glopal is exposign public API that can be used in site JavaScript code in such scenarios.

Link rewrite

Method window.glopal.localizeUrl() can be used to get localized links for the current site.

// localizeUrl(url: string): string

window.glopal.localizeUrl("https://www.example.com/en/product");
// On FR localized site, result: https://fr.example.com/fr/product

Translations

Method window.glopal.localize() can be used to get translations inside your code:

// type LocalizeArgs = string[] | { [key: string]: string };
// localize<T extends LocalizeArgs>(args: T): Promise<T>

window.glopal.localize([
  "Monday",
  "Tuesday",
  "Wednesday"
]).then(data => console.log(data)); // ["Poniedziałek", "Wtorek", "Środa"]

window.glopal.localize({
  "monday": "Monday",
  "tuesday": "Tuesday",
  "wednesday": "Wednesday"
}).then(data => console.log(data)); // {"monday": "Poniedziałek", "tuesday": "Wtorek", "wednesday": "Środa"}
PreviousCSS customizationsNextServer-side customizations

Last updated 1 year ago

If localizing visible elements, it is required to apply on already localized content to avoid double-localization.

gp-noloc attributes