Go to https://{{your_shopify_domain}}/admin/themes/{{your_theme_code}}/language?category=checkout+%26+system
Open your browser console and paste this code:
var obj = {};
$(".translation__target").each(function() {
var value = this.children[0].value ? this.children[0].value : this.children[0].placeholder
_.set(obj, this.children[0].dataset.key, value);
});
var data = window.URL.createObjectURL(new Blob([JSON.stringify(obj, null, 2)], {type: "application/json;charset=utf-8;"}));
$("<a download='en.system_keys.json'></a>").appendTo($("body")).attr('href', data)[0].click();
Open your browser console and paste this code:
var jsonToMerge = "https://raw.githubusercontent.com/QuintinS/shopcreatify-elivar-eu/master/locales/zh-CN.json"
var mergeData = function(body) {
var obj = {};
var chinese = JSON.parse(body);
var getText = function(key, fallback) {
return (_.get(chinese, key)) ? _.get(chinese, key) : fallback;
};
$(".translation__target").each(function() {
_.set(obj, this.children[0].dataset.key, getText(this.children[0].dataset.key, this.children[0].placeholder));
});
var data = window.URL.createObjectURL(new Blob([JSON.stringify(obj, null, 2)], {type: "application/json;charset=utf-8;"}));
$("<a download='zh-CN.json'></a>").appendTo($("body")).attr('href', data)[0].click()
}
$.get(jsonToMerge, mergeData);
The browser will download your JSON file with Shopify translation keys
Hi,
thanks a lot for doing it!
My question is: can I get Shopify system keys + those that are already translated?
I really appreciate any help :)
#edit: Already done it by changing ".placeholder" to ".value"