Learn how to ship impactful customer journeys with Builder

Announcing Visual Copilot - Figma to production in half the time

Builder.io logo
Contact Sales
Platform
Developers
Contact Sales

Blog

Home

Resources

Blog

Forum

Github

Login

Signup

×

Visual CMS

Drag-and-drop visual editor and headless CMS for any tech stack

Theme Studio for Shopify

Build and optimize your Shopify-hosted storefront, no coding required

Resources

Blog

Get StartedLogin

Pro plans

To use localization with Builder, you must integrate with your codebase so that your app and Builder localization coordinate with one another. This entails:

  1. Passing the locale to the BuilderComponent or Content. depending on your SDK. For details on the SDKs, read SDK Comparison.
  2. Passing the locale value in the options object when fetching content from the API to get JSON with resolved, localized values.

Though the syntax varies depending on the framework, the concept is the same. Select your framework below for examples.

Tip: Passing the locale to the BuilderComponent or Content emits the locale while previewing or editing so the Visual Editor displays localized values.

For whole-content entry localization, specify your locale as a targeting attribute when fetching your Builder content from the Content API.

Integrating localization with Builder Data models is the same as with Page or Section models except that you don't render anything in your code for a Data model. This means that for integrating a Data model, you don't need BuilderComponent for Gen 1 or Content for Gen 2 SDKs.

For more detail on setting up localization in the Builder Data model UI, visit Localizing Data Models.

For example, given a greeting object, with localized values for en-US and fr-Fr, Builder would transform it to Hello or Bonjour depending on the locale:

// orginal object with values for each locale
"greeting": {
  "en-US": "Hello",
  "fr-Fr": "Bonjour"
}

Builder transforms the object to use the value that corresponds to the locale, as follows:

// locale=en-US
"greeting":"Hello"
// locale=fr-Fr
"greeting": "Bonjour"

Ideally, you want your app to dynamically adjust to the user's locale.

You can automatically determine the user’s locale based on their system settings by using the Intl.DateTimeFormat() locale and passing it into the locale option:

const res = await fetchOneEntry({
  model: 'page',
  apiKey,
  options: {
    ...getBuilderSearchParams(new URL(location.href).searchParams),
    locale: new Intl.DateTimeFormat().resolvedOptions().locale
  },
  userAttributes: {
    urlPath: window.location.pathname,
  },
});

When your codebase and Builder localization are successfully integrated, you can use any of Builder's localization techniques.

Was this article helpful?

Product

Visual CMS

Theme Studio for Shopify

Sign up

Login

Featured Integrations

React

Angular

Next.js

Gatsby

Get In Touch

Chat With Us

Twitter

Linkedin

Careers

© 2020 Builder.io, Inc.

Security

Privacy Policy

Terms of Service

Newsletter

Get the latest from Builder.io

By submitting, you agree to our Privacy Policy

Product

Platform Overview

Integrations

What's New

Open Source

Builder

Builder

Mitosis

Mitosis

Qwik

Qwik

Partytown

Partytown

Popular Guides

From Design to Code Guide

Composable Commerce Guide

Headless CMS Guide

Headless Commerce Guide

Composable DXP Guide

Design to Code

Resources

Blog

Knowledge Base

Community Forum

Partners

Templates

Success Stories

Showcase

Resource Center

Frameworks

React

React

Next

Next.js

Qwik

Qwik

Gatsby

Gatsby

Angular

Angular

Vue

Vue

Svelte

Svelte

Remix logo

Remix

Nuxt

Nuxt

Hydrogen

Hydrogen

See All

© 2024 Builder.io, Inc.

Security

Privacy Policy

SaaS Terms

Security & Compliance

Cookie Preferences

Gartner Cool Vendor 2024