mirror of
https://github.com/pepaskopec-blip/Graduately.git
synced 2026-10-28 07:34:34 +00:00
Add the Next.js web app and shared lesson content.
Move lessons out of the C sources into JSON so the web client can use the same material as the desktop app, and point release builds at desktop/. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
4708c69d9c
commit
f7470d333c
113 changed files with 25817 additions and 9 deletions
35
tools/extract/i18n.mjs
Normal file
35
tools/extract/i18n.mjs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { readFileSync } from 'node:fs';
|
||||
import { parseArray } from '../lib/cparse.mjs';
|
||||
|
||||
/**
|
||||
* `tr_ui` holds UI chrome keyed by short identifiers; `tr_content` holds
|
||||
* lesson text keyed by the Czech string itself (its `cs` column is usually
|
||||
* NULL, meaning "the key already is the Czech text").
|
||||
*/
|
||||
function toTable(entries, { keyIsCzech }) {
|
||||
const cs = {};
|
||||
const en = {};
|
||||
|
||||
for (const row of entries) {
|
||||
if (!Array.isArray(row)) continue;
|
||||
const [key, csText, enText] = row;
|
||||
if (key === null || key === undefined) continue; // terminator
|
||||
|
||||
cs[key] = csText ?? (keyIsCzech ? key : null);
|
||||
if (enText !== null && enText !== undefined) en[key] = enText;
|
||||
}
|
||||
|
||||
// A null Czech value in tr_ui would render as an empty label; drop it.
|
||||
for (const k of Object.keys(cs)) if (cs[k] === null) delete cs[k];
|
||||
|
||||
return { cs, en };
|
||||
}
|
||||
|
||||
export function extractI18n(desktopDir) {
|
||||
const src = readFileSync(`${desktopDir}/i18n.c`, 'utf8');
|
||||
|
||||
return {
|
||||
ui: toTable(parseArray(src, 'tr_ui'), { keyIsCzech: false }),
|
||||
content: toTable(parseArray(src, 'tr_content'), { keyIsCzech: true }),
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue