8000 fixes · devforth/scriptimate@698a43d · GitHub
[go: up one dir, main page]

Skip to content

Commit 698a43d

Browse files
committed
fixes
1 parent acf6095 commit 698a43d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

bin/scriptimate.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ const schedule_eval = (name, ms, ...rest) => {
406406
parts[part].content = value;
407407
global[part+'_value'] = value;
408408
}
409-
eval(code)
409+
eval(code);
410410
},
411411
+ms
412412
)
@@ -473,7 +473,6 @@ const runGeneration = async (lang) => {
473473

474474
const html = genHtml(parts);
475475
const hash = crypto.createHash('sha1').update(html).digest('base64url');
476-
await fs.writeFile(`${FRAMES_DIR}/_index111.html`, html)
477476
frameHashByAbsIndex[cntr] = hash;
478477

479478
if (!frameAbsIndexByHTMLHash[hash]) {
@@ -526,11 +525,24 @@ const runGeneration = async (lang) => {
526525
await fs.mkdir(FRAMES_DIR, { recursive: true });
527526

528527
const processed_lines = []
529-
for (const line of script.split('\n')) {
528+
for (const lineIter of script.split('\n')) {
529+
let line = lineIter;
530530
if (!line.trim() || line.trim().startsWith(';')) {
531531
// empty line
532532
continue;
533533
}
534+
if (lang !== 'default') {
535+
const strings = translationsDict[lang];
536+
Object.keys(strings).forEach((tr) => {
537+
// not tested but should prevent from b64 strigs to be affected by translations
538+
// withUniquifiedIDs = withUniquifiedIDs.replace(new RegExp(`>(.+?)${tr}(.+?)<`, 'g'), (_, v1, mid, v2) => {
539+
// return `>${v1}${strings[tr]}${v2}<`;
540+
// });
541+
// allows to translate constants in script too
542+
line = line.replaceAll(`'${tr}'`, `'${strings[tr]}'`).replaceAll(`"${tr}"`, `"${strings[tr]}"`);
543+
});
544+
}
545+
534546
if (line.trim().startsWith('&&')) {
535547
processed_lines[processed_lines.length - 1] += ` ${line.trim()} `;
536548
} else {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scriptimate",
3-
"version": "1.2.21",
3+
"version": "1.2.22",
44
"description": "Open-source SVG animation tool",
55
"main": "bin/index.js",
66
"keywords": [

0 commit comments

Comments
 (0)
0