Advertisement
Guest User

Convert Numbers (Western to Arabic-Indic)

a guest
May 7th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.79 KB | None | 0 0
  1. /* :name = Convert Numbers (Western to Arabic-Indic)   :description=Transliterates any Western digit, if found, to its Arabic-Indic counterpart
  2.  * @author      Manuel Souto Pico
  3.  * @date        2019-05-07
  4.  * @version     0.0.1
  5.  */
  6.  
  7. def gui(){
  8.     def segm_count = 0
  9.     def pattern;
  10.  
  11.     pattern = /[0-9]/
  12.    
  13.     project.allEntries.each { ste ->
  14.  
  15.         def target = project.getTranslationInfo(ste) ? project.getTranslationInfo(ste).translation : null;
  16.      
  17.         if (target.find(pattern) != null)
  18.         {
  19.             segm_count++
  20.             editor.gotoEntry(ste.entryNum())
  21.            
  22.             def repl = target.tr('0123456789', '٠١٢٣٤٥٦٧٨٩')
  23.  
  24.             console.println(ste.entryNum() + "\t" + target + " => " + repl)
  25.             editor.replaceEditText(repl)
  26.         }
  27.     }
  28.     console.println(segm_count + " segments modified")
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement