| 33 | } |
| 34 | |
| 35 | function extractExpression( |
| 36 | expression: SvelteNode | null | undefined, |
| 37 | source: string, |
| 38 | parseScriptFn: ScriptParseFn |
| 39 | ): void { |
| 40 | if (!expression || expression.start == null || expression.end == null) { |
| 41 | return |
| 42 | } |
| 43 | const content = source.slice(expression.start, expression.end) |
| 44 | try { |
| 45 | parseScriptFn(`(${content})`) |
| 46 | } catch (e) { |
| 47 | console.warn( |
| 48 | `Failed to parse "${content}". Ignore this if content has no extractable message`, |
| 49 | e |
| 50 | ) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | function getStringAttributeValue(value: SvelteNode): string { |
| 55 | return value.data ?? value.raw ?? '' |