Shared text extraction patterns and utilities for all parsers. Handles HTML entities, ignore patterns, and Transloco expression cleanup.

Methods

(inner) cleanTranslocoCode(code) → {string}

Removes Transloco function calls from TypeScript code.

Parameters:
NameTypeDescription
codestring
Returns:
Type: 
string

(inner) cleanTranslocoExpressions(template, skipTranslatedopt) → {string}

Removes already-translated Transloco expressions from template.

Parameters:
NameTypeAttributesDefaultDescription
templatestring
skipTranslatedboolean<optional>
true
Returns:
Type: 
string

(inner) decodeHtmlEntities(str) → {string}

Decodes HTML entities to their character equivalents.

Parameters:
NameTypeDescription
strstring
Returns:
Type: 
string
Example
decodeHtmlEntities('&amp;') // '&'

(inner) extractWithPatterns(content, patterns, optionsopt) → {Array.<ExtractedText>}

Extracts translatable text using regex patterns.

Parameters:
NameTypeAttributesDescription
contentstring
patternsArray.<Object>
optionsObject<optional>
Returns:
Type: 
Array.<ExtractedText>

(inner) isTranslationKey(text) → {boolean}

Checks if text looks like a translation key (dot-separated).

Parameters:
NameTypeDescription
textstring
Returns:
Type: 
boolean
Example
isTranslationKey('common.buttons.save') // true

(inner) shouldIgnore(text) → {boolean}

Determines if text should be ignored (too short, numeric, URL, etc.).

Parameters:
NameTypeDescription
textstring
Returns:
Type: 
boolean

Type Definitions

ExtractedText

Type:
  • Object
Properties
NameTypeAttributesDescription
textstring
rawTextstring
contextstring
attrstring<optional>