Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Automatically replace text value on SketchAPP, ideal for localization!. Just copy & paste the following script on Plugin->Custom Plugin
// Author: Victor Corvalan
var mkt01 = "#";
var mkt02 = "#";
var font_name = "";
var doc = context.document;
mkt01 = [doc askForUserInput:'Text to replace:' initialValue:''];
mkt02 = [doc askForUserInput:'New text value:' initialValue:''];
font_name = [doc askForUserInput:'Change FONT:' initialValue:''];
var layers;
for (var i = 0; i < doc.pages().count(); i++) {
var page = doc.pages().objectAtIndex(i);
layers = page.children();
// Loop through all children of the page
for (var j = 0; j < layers.count(); j++) {
// get the current layer
var layer = layers.objectAtIndex(j);
// Check if the layer is a text layer
if(layer.class() == "MSTextLayer") {
if( == mkt01.toLowerCase()){
if(font_name != ""){
function refreshTextLayer(layer) {
[layer select: true byExpandingSelection: false];
[layer setIsEditingText: true];
[layer setIsEditingText: false];
[layer select: false byExpandingSelection: false];
[layer adjustFrameToFit];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment