( text: string, start?: number )
| 117 | } & Pick<Opts, 'onMsgExtracted' | 'onMetaExtracted'> |
| 118 | |
| 119 | function calculateLineColFromOffset( |
| 120 | text: string, |
| 121 | start?: number |
| 122 | ): Pick<ExtractedMessageDescriptor, 'line' | 'col'> { |
| 123 | if (!start) { |
| 124 | return {line: 1, col: 1} |
| 125 | } |
| 126 | const chunk = text.slice(0, start) |
| 127 | const lines = chunk.split('\n') |
| 128 | const lastLine = lines[lines.length - 1] |
| 129 | return {line: lines.length, col: lastLine.length} |
| 130 | } |
| 131 | |
| 132 | function isBuiltinFormatter( |
| 133 | format: ExtractOpts['format'] |