Skip to main content
Participating Frequently
June 25, 2023
Question

Transliteration of numbers into text

  • June 25, 2023
  • 2 replies
  • 288 views

Hi to all!

 

My boss asked me to transliterate for her all the numbers she writes in a certain InDesign text frame.

I tried with Find and Replace with regular expressions, and no success.

Also, I tried some scripts, but maybe I did not find a good one to do this for me.

Thank you to anyone who can do this.

 

Dumitru. 

This topic has been closed for replies.

2 replies

Community Expert
June 25, 2023

Sounds interesting, without knowing the context of the text being captured I used some sample text and this seems to work for me.

 

quote

Imagine walking into a bustling market where vendors enthusiastically advertise their wares. A sign catches your eye: ‘Special Deal: Buy 2, Get 1 Free!’ The excitement builds as you browse through a variety of items with price tags in bold fonts, ranging from $9.99 to $99.99. As you make your way to the fruit section, you notice a vendor shouting, ‘Fresh oranges, only 3 for $2!’ Nearby, a vendor proudly displays a massive watermelon weighing a whopping 15 kilograms, while another boasts about their record-breaking pumpkin weighing in at 150 pounds. In the distance, a street performer announces, ‘Come see the incredible juggler! He can juggle up to 5 flaming torches at once!’ Your curiosity piqued, you head towards the performance area, where a crowd has gathered to witness the spectacle. The performer flawlessly juggles torches as the audience gasps in amazement. In the midst of the excitement, a young girl approaches you, selling handmade bracelets for just $5 each. You decide to support her talent and buy 2, handing her a $10 bill. With a wide smile, she thanks you, making your day even brighter.

 

 

var activeDocument = app.activeDocument;

var pasteboardTextFrame = app.activeWindow.activeSpread.pages[0].textFrames.add();
pasteboardTextFrame.geometricBounds = [0, -50, 250, 0]; // Adjust the dimensions as needed

// Define any extra text to be caputured, i.e, currency
var currencySymbols = ["\\$", "€", "£", "¥"]; // Escape the "$" symbol with "\\" to match it literally

var regexPattern = "(?:(?:" + currencySymbols.join("|") + ")\\s*)?(\\d+(?:\\.\\d+)?)";

for (var i = 0; i < activeDocument.stories.length; i++) {
  var story = activeDocument.stories[i];
  
  for (var j = 0; j < story.paragraphs.length; j++) {
    var paragraph = story.paragraphs[j];
    
    var matches = paragraph.contents.match(new RegExp(regexPattern, "g"));
    
    if (matches) {

      for (var k = 0; k < matches.length; k++) {
        var match = matches[k];
        
        pasteboardTextFrame.contents += match + "\n";
      }
    }
  }
}

 

 

Participating Frequently
June 26, 2023

I will check it out. I did not have time, I was working today, but I will definetly do it. Thank you very much.

m1b
Community Expert
Community Expert
June 25, 2023

Hi @dumitrus56120735 what is the transliteration? Can you post a sample document with before and after?

-Mark

Participating Frequently
June 26, 2023

My boss wants to write a sum, e.g., 123456, and she wants to see the transliteration of it as, onehundredtwentythreethousandfourhundredfiftysix exactly like this with no break between words.

Thank you.