Advertisement
kopyl

Old FakeTranslate figma

Oct 20th, 2021
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fakeTranslate = async() => {
  2.    
  3.     let charArray = fSelected().characters.split(" ")
  4.     let wordslengths = charArray.map(i => i.length)
  5.    
  6.     if (wordslengths.every(i => i == 8)) return
  7.    
  8.     await figma.loadFontAsync( fSelected().fontName )
  9.    
  10.    
  11.     const characters ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  12.  
  13.     function generateString(length) {
  14.         let result = '';
  15.         const charactersLength = characters.length;
  16.         for ( let i = 0; i < length; i++ ) {
  17.             result += characters.charAt(Math.floor(Math.random() * charactersLength));
  18.         }
  19.    
  20.         return result.toLowerCase();
  21.     }
  22.    
  23.     for (let n = 0; n<charArray.length; n++) {
  24.         if (wordslengths[n] <13) {
  25.             if (!isNaN(charArray[n])) {continue}
  26.             charArray[n] = charArray[n] + "s" + generateString(11-wordslengths[n])
  27.         }
  28.     }
  29.    
  30.     fSelected().name = fSelected().characters
  31.    
  32.     fSelected().characters = charArray.join(" ")
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement