How To Translate Exactly What You Need With Regex Filter?

How To Translate Exactly What You Need With Regex Filter?

Share on social media:

Customization rules! Customization of translation approach, customization of files to translate, content customization for your clients and customization of anything that can help you go global in a way that is perfect for you! Last time we wrote about advanced Excel filters and how they help to keep the files translation-friendly, exclude HTML elements and enable to pick what we need to translate, whether be it language or any other preference. But let’s not forget that resource files coming from your CMS or software are not only Excel files (obviously and perhaps, fortunately).

Regex filter for translation

What about extracting and customizing the content that we want to translate from .php files? What about .json, .resx and .xliff? We want you to be able to fish out what you need and enable the developers to take the advantage of this possibility, too. What to do? Here, all in white comes the Regex filter for files where the filters do not have custom options available. With this little one, your developers can clearly define what should be extracted from a file. Want to get to know it better and learn how to use it? All you have to do is keep on reading.

Meet the Regex Filter

In short, The Regex filter serves as a general-purpose text filter. It allows you to select any lines of text matching a regular expression pattern. It is pretty simple, yet genius, but you need to remember that when you upload a file in Text United, the system will automatically assign a filter based on the file extension. Logically, the Regex filter will never be selected as default because it’s not linked to any extension particularly.

Why its multipurposeness is so valuable? It’s a perfect a tool for a project manager. If you are one, it will allow you define exactly which content should be extracted. That’s why regex filter can be life-saving when it comes to translation.

How to Define Exactly What Text to Extract From a File?

#1. You must provide the regex pattern in the Regex Options field:


It allows to parse a file line by line and compare it with the pattern. When the match is found, the line will be processed as a segment for translation. However, nearly in all cases, only a part of the line needs to be extracted for translation. That’s why the regex pattern must include at least one regex group (the part in parentheses) that references the text for translation.

#2. Regex groups have their numbers. Using the group number allows the user to choose, which exactly group should be translated. It helps the filter to find a position where the translation must be put back after the file is reverted.

#3. The default pattern of the Regex filter is: (.*). Basically, it works as a plain text filter extracting all the text (each line).



#4. We want to extract content in between the quotes: View profile, Logout, Dashboard etc. First find the lines using a regex that matches any number of space characters (spaces or tabs), then an apostrophe, any number of characters, another apostrophe, zero or more space characters, a literal string of =>, zero or more space characters, apostrophe, one or more characters ending with a literal apostrophe.

#5. There may be any number of characters after the last apostrophe to the end of the line. The pattern below will do the trick:


#6. Having the lines of interest we can specify the text we actually want to translate. We can simply define a group (the one and only in this case) by surrounding the part referencing to the text with parentheses:


This is how the entered regex pattern will affect the filter:


There you go, you just extracted exactly what you needed.


Long Live Customization and Multipurposeness!