mirror of
https://github.com/frappe/books.git
synced 2026-08-24 10:04:45 -05:00
incr: fetch translateables from schema.json
- use legit csv
This commit is contained in:
+2
-5
@@ -49,11 +49,8 @@ function splitCsvBlock(text: string, splitter: string = '\r\n'): string[] {
|
||||
return lines;
|
||||
}
|
||||
|
||||
function splitCsvLine(line: string): string[] {
|
||||
if (line.at(-1) !== ',') {
|
||||
// if conforming to spec, it should not end with ','
|
||||
line += ',';
|
||||
}
|
||||
export function splitCsvLine(line: string): string[] {
|
||||
line += ',';
|
||||
|
||||
const items = [];
|
||||
let item = '';
|
||||
|
||||
@@ -57,34 +57,3 @@ export function getWhitespaceSanitized(str: string) {
|
||||
export function getIndexList(str: string) {
|
||||
return [...str.matchAll(/\${([^}]+)}/g)].map(([_, i]) => parseInt(i));
|
||||
}
|
||||
|
||||
export function wrap(str: string) {
|
||||
return '`' + str + '`';
|
||||
}
|
||||
|
||||
export function splitCsvLine(line: string) {
|
||||
let t = true;
|
||||
const chars = [...line];
|
||||
const indices = chars
|
||||
.map((c, i) => {
|
||||
if (c === '`') {
|
||||
t = !t;
|
||||
}
|
||||
|
||||
if (c === ',' && t) {
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
})
|
||||
.filter((i) => i !== -1);
|
||||
|
||||
let s = 0;
|
||||
const splits = indices.map((i) => {
|
||||
const split = line.slice(s, i);
|
||||
s = i + 1;
|
||||
return split.trim();
|
||||
});
|
||||
splits.push(line.slice(s).trim());
|
||||
return splits.filter((s) => s !== ',' && s !== '');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user