This example changes the source text so that it matches the customers style guide. In this example, the following terms need to be replaced with the word "Platform":

  • Aircraft/Platform
  • Aircraft or Platform
  • Platform or Aircraft
  • Platform/Aircraft


If the term "Aircraft" is seen in any other form, the it will not be changed.


This is a common scenario where the target text desired may be slightly different to the source text. This can be achieved by modifying the source text before it is translated.


 

 

//Language Studio Pre-Processing Script
//Copyright 2008-2016 Omniscien Technologies Pte Ltd. All Rights Reserved.

//Description:
//Example of simple rule to transform text using a regular expression. 
//All occurrences of  “Aircraft/Platform” or “Platform/Aircraft” or "Aircraft or Platform" or "Platform or Aircraft" need to be translated as “Platform”.  
//However, if the word “aircraft” occurs by itself, it needs to be translated as “aircraft.”

function main(sAllSourceSegments) {

    //Match the pattern 
    sAllSourceSegments = sAllSourceSegments.replace(RegExp(/([ ]{0,})(aircraft|platform)([ ]{0,}(or|\/)[ ]{0,})(aircraft|platform)([ ]{0,})/gmi), " Platform ");
    
    // Return output
    return sAllSourceSegments;
}