Shared text extraction patterns and utilities for all parsers. Handles HTML entities, ignore patterns, and Transloco expression cleanup.
- Source
Methods
(inner) cleanTranslocoCode(code) → {string}
Removes Transloco function calls from TypeScript code.
Parameters:
| Name | Type | Description |
|---|---|---|
code | string |
- Source
Returns:
- Type:
- string
(inner) cleanTranslocoExpressions(template, skipTranslatedopt) → {string}
Removes already-translated Transloco expressions from template.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
template | string | |||
skipTranslated | boolean | <optional> | true |
- Source
Returns:
- Type:
- string
(inner) decodeHtmlEntities(str) → {string}
Decodes HTML entities to their character equivalents.
Parameters:
| Name | Type | Description |
|---|---|---|
str | string |
- Source
Returns:
- Type:
- string
Example
decodeHtmlEntities('&') // '&'(inner) extractWithPatterns(content, patterns, optionsopt) → {Array.<ExtractedText>}
Extracts translatable text using regex patterns.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
content | string | ||
patterns | Array.<Object> | ||
options | Object | <optional> |
- Source
Returns:
- Type:
- Array.<ExtractedText>
(inner) isTranslationKey(text) → {boolean}
Checks if text looks like a translation key (dot-separated).
Parameters:
| Name | Type | Description |
|---|---|---|
text | string |
- Source
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:
| Name | Type | Description |
|---|---|---|
text | string |
- Source
Returns:
- Type:
- boolean
Type Definitions
ExtractedText
Type:
Properties- Object
| Name | Type | Attributes | Description |
|---|---|---|---|
text | string | ||
rawText | string | ||
context | string | ||
attr | string | <optional> |
- Source