Getting Started
About Stencil
Transitioning to Stencil
Installing Stencil
Authentication & Tokens
Running Stencil Locally
Advanced Installation Options
Template Files
Templates Directory
Custom Templates
Customize Stencil Checkout
Handlebars and Stencil
Handlebars.js Overview
Handlebars Helpers
Stencil Object Model
Stencil Objects

Invoking Translation Keys

Translation Syntax

Once keys and values are defined in the .json translation files, you can invoke dynamic translation strings using the the custom {{lang}} Handlebars helper. Your invocation would follow this generic format:

Translation invocation
{{lang "translation.key" optionalVariable=”someValue”}}

Here is how this works. In a non-internationalized theme, a storefront page might include a string like this:

Non Internationalized string
<a href="{{ urls.account }}">Welcome Back <span>{{ }}</span></a>

The corresponding internationalized version would substitute the text with the fully dynamic {{ lang }} Handlebars helper shown below:

Internationalized String using {{lang}} Handlebars Helper
<a href="{{ urls.account }}">{{ lang "header.welcome_back" }}</a>

Video Demo

Watch a video demonstration of how JSON translation files’ key/value pairs interact with your templates’ Handlebars statements to localize your storefront pages:

File Permissions Required

Be sure to set permission 644 (rw-r–r–) on any new translation files that you add. Without these permissions, running your theme locally will fail, with multiple error messages. Bundling your theme will also fail, blocking its upload to a store.