Shopify Admin Translator is a small chrome extension that tries to translate as much as it can from the Shopify Admin in different languages. It works by using standardized CSS selectors to select part of the application, translating them on the fly based on your selected language using simple javascript rules.
This is best used by Shopify merchants for which English isn't their primary language. If you're a Shopify Partner or Expert who'd like to help or sell Shopify to non-English merchants, feel free to use this app as well, free of charge.
No. Shopify Admin is huuuge, and evolve on a daily basis. It's impossible for us to keep track of all new strings, all new texts that are added daily. That being said, we believe this translates enough to still be useful, and we'll always default to the original text if we can't find a translation so you don't lose anything.
Shopify Admin Translator relies on pattern matching to find snippets of text, replacing them with some well defined rules. Imaginine the following;
// tree.js
{
'.next-nav': {
'.next-nav__panel--primary': {
'[data-nav-section]': {
'.next-nav__text': 'general.sections.$data-nav-section.$text'
}
}
}
}
This instructs the parser to;
- Find all html elements with a
next-nav
class; - Within those, find all elements with a
next-nav__panel--primary
class; - Within those, find all elements with a
data-nav-section
attribute; - Within those, find all elements with a
next-nav__text
class; - For all of them, replace the inner text with something.
Now, how do we define that something? The parser uses a smart combination of namespaces, variables and keys to determine how the text should be replaced. In the above example, general.sections.$data-nav-section.$text
, we see a couple of things;
-
general
,section
Those are namespaces. We use them to keep translated strings in logical groups. -
$data-nav-section
All elements starting with a$
represents a variable. Every time we instruct the parser to find elements based on an attribute, the parser keeps track of the value of that attribute, making it available for further usage through a$
variable, using the name of said attribute. -
$text
This one is a special variable representing a sanitized representation of the inner text of the current element. Spaces and special characters are all stripped out, making them suitable for the parser to use as keys. As an example, "Hello, world" would be sanitized as "hello-world".
So to go back to our general.sections.$data-nav-section.$text
example, we instruct the parser to;
- Within the
general
namespace; - Within the
sections
namespace; - Within a namespace named after the
[data-nav-section]
attribute value; - Within a namespace named after the current text;
- Return the translated string.
All translations sit in javascript files using a format that allow the parser to follow those instructions and find the proper translated string.
// locales/fr.js
{
'general': {
'sections': {
'section-1': {
'order': "Commande",
'draft': "Pré-Commande"
},
'section-2': {
'checkout': "Panier",
'customer': "Client"
}
}
}
}