1. Home
  2. Docs
  3. Translator++
  4. Code Escaping Algorithm
  5. Custom Pattern

Custom Pattern

Code escaper is a feature that will let us exclude some words, phrases, codes when performing batch translations.

This feature is useful for escaping codes, path to resources or any string that should not be translated from being translated by machine when doing batch translation.

Compatibility

This feature is only available on the “Hex Placeholder” escape algorithm.

How to access the tool

Options window → Translator & Language → Custom Escaper → Patterns

How to write the patterns

Patterns are valid JavaScript strings, functions, or Regular Expressions. Each pattern is separated by a comma.

Literal Strings

We can write patterns with literal javascript strings. This is useful to escape simple phrases or a word.

  • String is a JavaScript strings
  • Strings are enclosed with double quotes, single quotes or a backticks (template literals).
  • You must escape special characters with a backslash (for example type backslash with double backslash)

Example

JS

Functions

We can write patterns with a javascript function. You can access all javascript’s native function and Translator++ environment’s function.

This functionality is useful for escaping miscellaneous words, for example to exclude the first line of each message, etc.

  • Function is unnamed function
  • Any type of functions are acceptable (async function, arrow functions)
  • First parameters are the current string of the text, that can be the entire text key of each row (on row-by-row mode) or each line of each row (on line-by-line mode)
  • The function should returns array of string to be escaped

Example

JS

Regular expressions

Regular expressions also can be used to filter out text from translation.

  • Any form of Ecmascript regular expressions are accepted
  • Write regular expressions along with its modifier

Example

JS

Commenting

Pattern fields also allow us to put JavaScript styled comments such as double slash for line commenting, or multiple line commenting with /* */

JS

Was this article helpful to you? Yes No