Refactor and expand Translation and Quest management.
This commit is contained in:
parent
4660216504
commit
5f21775771
20 changed files with 2546 additions and 9969 deletions
|
@ -6,11 +6,24 @@ import dotenv from 'dotenv';
|
|||
|
||||
dotenv.config({ path: '.env' }).parsed;
|
||||
|
||||
const normalizeTranslation = (translation: string | null | undefined) => {
|
||||
if (translation == null) {
|
||||
return '';
|
||||
}
|
||||
return translation.replace(/\n/g, '\\n').replace(/"/g, "'");
|
||||
};
|
||||
|
||||
const prepareLuaWithFemaleVersion = (quest: Quest, type: keyof Quest, key: string) => {
|
||||
let text = '';
|
||||
const value = quest[type] as string;
|
||||
text += '\t' + key + 'Male = "' + (value?.[0]?.replace(/\n/g, '\\n') ?? '').replace(/"/g, "'") + '", \n';
|
||||
text += '\t' + key + 'Female = "' + (value?.[1]?.replace(/\n/g, '\\n') ?? '').replace(/"/g, "'") + '", \n';
|
||||
const normalizedMaleValue = normalizeTranslation(value?.[0]);
|
||||
const normalizedFemaleValue = normalizeTranslation(value?.[1]);
|
||||
if (normalizedMaleValue != '') {
|
||||
text += '\t' + key + 'Male = "' + normalizedMaleValue + '", \n';
|
||||
}
|
||||
if (normalizedFemaleValue != '') {
|
||||
text += '\t' + key + 'Female = "' + normalizedFemaleValue + '", \n';
|
||||
}
|
||||
return text;
|
||||
};
|
||||
|
||||
|
@ -53,7 +66,7 @@ function makeChunks(input: AddonData, chunkSize: number = 1000) {
|
|||
|
||||
(async () => {
|
||||
const args = process.argv.slice(2);
|
||||
const addonDir = path.join(process.cwd(), `../Quests/Data/${args[0]}`);
|
||||
const addonDir = path.join(process.cwd(), `../Addon/Data/${args[0]}`);
|
||||
|
||||
const addonData: Record<string, Quest> = {};
|
||||
let pageNumber = 0;
|
||||
|
@ -63,7 +76,7 @@ function makeChunks(input: AddonData, chunkSize: number = 1000) {
|
|||
while (true) {
|
||||
const response = await callTolgee<TolgeeTranslationsResponse>('GET', `/translations`, {
|
||||
filterTranslatedInLang: 'cs',
|
||||
languages: 'cs,csf',
|
||||
languages: 'cs,csf,en',
|
||||
size: 2000,
|
||||
page: pageNumber,
|
||||
});
|
||||
|
@ -97,6 +110,7 @@ function makeChunks(input: AddonData, chunkSize: number = 1000) {
|
|||
tolgeeKey.translations.cs.text === tolgeeKey.translations.csf.text
|
||||
? null
|
||||
: tolgeeKey.translations.csf.text,
|
||||
tolgeeKey.translations.en.text,
|
||||
],
|
||||
}),
|
||||
...(tolgeeKey.keyNamespace === 'progress' && {
|
||||
|
@ -117,7 +131,9 @@ function makeChunks(input: AddonData, chunkSize: number = 1000) {
|
|||
}),
|
||||
name: tolgeeKey.keyDescription,
|
||||
id: tolgeeKey.keyName.replace('q', '').replace('i', ''),
|
||||
questItem: tolgeeKey.keyName.startsWith('i'),
|
||||
isQuest: tolgeeKey.keyName.startsWith('q'),
|
||||
isQuestItem: tolgeeKey.keyName.startsWith('i'),
|
||||
isSpeech: tolgeeKey.keyName.startsWith('s'),
|
||||
};
|
||||
}
|
||||
} else {
|
||||
|
@ -136,25 +152,36 @@ function makeChunks(input: AddonData, chunkSize: number = 1000) {
|
|||
} catch (e) {}
|
||||
for (const [, czechQuest] of Object.entries(chunk)) {
|
||||
// prepare variables
|
||||
let variableTable = 'quest';
|
||||
let variableId = czechQuest.id;
|
||||
|
||||
// if quest is quest item witch pages, store it inside item table
|
||||
if (czechQuest.questItem) {
|
||||
variableTable = 'item';
|
||||
const page = czechQuest.id.split('_page')?.[1] ?? null;
|
||||
variableId = `"${czechQuest.name}${page ? `__${page}` : ''}"`;
|
||||
if (czechQuest.isQuest) {
|
||||
let luaQuestRecord = '';
|
||||
luaQuestRecord += `CzechQuestsAddon.data.quest[${czechQuest.id}] = {\n`;
|
||||
luaQuestRecord += prepareLuaWithFemaleVersion(czechQuest, 'names', 'title');
|
||||
luaQuestRecord += prepareLuaWithFemaleVersion(czechQuest, 'objectives', 'objective');
|
||||
luaQuestRecord += prepareLuaWithFemaleVersion(czechQuest, 'descriptions', 'description');
|
||||
luaQuestRecord += prepareLuaWithFemaleVersion(czechQuest, 'progresses', 'progress');
|
||||
luaQuestRecord += prepareLuaWithFemaleVersion(czechQuest, 'completions', 'completion');
|
||||
luaQuestRecord += `}\n`;
|
||||
fs.appendFileSync(fileName, luaQuestRecord, 'utf8');
|
||||
}
|
||||
|
||||
let luaQuestRecord = '';
|
||||
luaQuestRecord += `CzechQuestsAddon.data.${variableTable}[${variableId}] = {\n`;
|
||||
luaQuestRecord += prepareLuaWithFemaleVersion(czechQuest, 'names', 'title');
|
||||
luaQuestRecord += prepareLuaWithFemaleVersion(czechQuest, 'objectives', 'objective');
|
||||
luaQuestRecord += prepareLuaWithFemaleVersion(czechQuest, 'descriptions', 'description');
|
||||
luaQuestRecord += prepareLuaWithFemaleVersion(czechQuest, 'progresses', 'progress');
|
||||
luaQuestRecord += prepareLuaWithFemaleVersion(czechQuest, 'completions', 'completion');
|
||||
luaQuestRecord += `}\n`;
|
||||
fs.appendFileSync(fileName, luaQuestRecord, 'utf8');
|
||||
if (czechQuest.isQuestItem) {
|
||||
const page = czechQuest.id.split('_page')?.[1] ?? null;
|
||||
const variableId = `"${czechQuest.name}${page ? `__${page}` : ''}"`;
|
||||
let luaQuestRecord = '';
|
||||
luaQuestRecord += `CzechQuestsAddon.data.item[${variableId}] = {\n`;
|
||||
luaQuestRecord += '\ttitle = "' + normalizeTranslation(czechQuest.name) + '", \n';
|
||||
luaQuestRecord += '\ttext = "' + normalizeTranslation(czechQuest.descriptions?.[0]) + '", \n';
|
||||
luaQuestRecord += `}\n`;
|
||||
fs.appendFileSync(fileName, luaQuestRecord, 'utf8');
|
||||
}
|
||||
|
||||
if (czechQuest.isSpeech) {
|
||||
let luaQuestRecord = '';
|
||||
luaQuestRecord += `CzechQuestsAddon.data.item["${czechQuest.descriptions?.[2]}"] = {\n`;
|
||||
luaQuestRecord += '\ttext = "' + normalizeTranslation(czechQuest.descriptions?.[0]) + '", \n';
|
||||
luaQuestRecord += `}\n`;
|
||||
fs.appendFileSync(fileName, luaQuestRecord, 'utf8');
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
|
@ -176,7 +203,9 @@ type Quest = {
|
|||
completions?: (string | null)[];
|
||||
objective?: string;
|
||||
objectives?: (string | null)[];
|
||||
questItem: boolean;
|
||||
isQuest: boolean;
|
||||
isQuestItem: boolean;
|
||||
isSpeech: boolean;
|
||||
};
|
||||
|
||||
type TolgeeKeysData = {
|
||||
|
|
119
downloader/pnpm-lock.yaml
generated
119
downloader/pnpm-lock.yaml
generated
|
@ -11,9 +11,15 @@ importers:
|
|||
axios:
|
||||
specifier: ^1.7.2
|
||||
version: 1.7.9
|
||||
diff:
|
||||
specifier: ^7.0.0
|
||||
version: 7.0.0
|
||||
dotenv:
|
||||
specifier: ^16.4.5
|
||||
version: 16.4.7
|
||||
pg:
|
||||
specifier: ^8.13.3
|
||||
version: 8.13.3
|
||||
typescript:
|
||||
specifier: 5.4.2
|
||||
version: 5.4.2
|
||||
|
@ -89,6 +95,10 @@ packages:
|
|||
resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==}
|
||||
engines: {node: '>=0.3.1'}
|
||||
|
||||
diff@7.0.0:
|
||||
resolution: {integrity: sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==}
|
||||
engines: {node: '>=0.3.1'}
|
||||
|
||||
dotenv@16.4.7:
|
||||
resolution: {integrity: sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==}
|
||||
engines: {node: '>=12'}
|
||||
|
@ -117,6 +127,56 @@ packages:
|
|||
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
pg-cloudflare@1.1.1:
|
||||
resolution: {integrity: sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==}
|
||||
|
||||
pg-connection-string@2.7.0:
|
||||
resolution: {integrity: sha512-PI2W9mv53rXJQEOb8xNR8lH7Hr+EKa6oJa38zsK0S/ky2er16ios1wLKhZyxzD7jUReiWokc9WK5nxSnC7W1TA==}
|
||||
|
||||
pg-int8@1.0.1:
|
||||
resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==}
|
||||
engines: {node: '>=4.0.0'}
|
||||
|
||||
pg-pool@3.7.1:
|
||||
resolution: {integrity: sha512-xIOsFoh7Vdhojas6q3596mXFsR8nwBQBXX5JiV7p9buEVAGqYL4yFzclON5P9vFrpu1u7Zwl2oriyDa89n0wbw==}
|
||||
peerDependencies:
|
||||
pg: '>=8.0'
|
||||
|
||||
pg-protocol@1.7.1:
|
||||
resolution: {integrity: sha512-gjTHWGYWsEgy9MsY0Gp6ZJxV24IjDqdpTW7Eh0x+WfJLFsm/TJx1MzL6T0D88mBvkpxotCQ6TwW6N+Kko7lhgQ==}
|
||||
|
||||
pg-types@2.2.0:
|
||||
resolution: {integrity: sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
pg@8.13.3:
|
||||
resolution: {integrity: sha512-P6tPt9jXbL9HVu/SSRERNYaYG++MjnscnegFh9pPHihfoBSujsrka0hyuymMzeJKFWrcG8wvCKy8rCe8e5nDUQ==}
|
||||
engines: {node: '>= 8.0.0'}
|
||||
peerDependencies:
|
||||
pg-native: '>=3.0.1'
|
||||
peerDependenciesMeta:
|
||||
pg-native:
|
||||
optional: true
|
||||
|
||||
pgpass@1.0.5:
|
||||
resolution: {integrity: sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==}
|
||||
|
||||
postgres-array@2.0.0:
|
||||
resolution: {integrity: sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
postgres-bytea@1.0.0:
|
||||
resolution: {integrity: sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
postgres-date@1.0.7:
|
||||
resolution: {integrity: sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
postgres-interval@1.2.0:
|
||||
resolution: {integrity: sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
prettier@3.2.5:
|
||||
resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==}
|
||||
engines: {node: '>=14'}
|
||||
|
@ -125,6 +185,10 @@ packages:
|
|||
proxy-from-env@1.1.0:
|
||||
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
|
||||
|
||||
split2@4.2.0:
|
||||
resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==}
|
||||
engines: {node: '>= 10.x'}
|
||||
|
||||
ts-node@10.9.2:
|
||||
resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==}
|
||||
hasBin: true
|
||||
|
@ -150,6 +214,10 @@ packages:
|
|||
v8-compile-cache-lib@3.0.1:
|
||||
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
|
||||
|
||||
xtend@4.0.2:
|
||||
resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==}
|
||||
engines: {node: '>=0.4'}
|
||||
|
||||
yn@3.1.1:
|
||||
resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==}
|
||||
engines: {node: '>=6'}
|
||||
|
@ -209,6 +277,8 @@ snapshots:
|
|||
|
||||
diff@4.0.2: {}
|
||||
|
||||
diff@7.0.0: {}
|
||||
|
||||
dotenv@16.4.7: {}
|
||||
|
||||
follow-redirects@1.15.9: {}
|
||||
|
@ -227,10 +297,57 @@ snapshots:
|
|||
dependencies:
|
||||
mime-db: 1.52.0
|
||||
|
||||
pg-cloudflare@1.1.1:
|
||||
optional: true
|
||||
|
||||
pg-connection-string@2.7.0: {}
|
||||
|
||||
pg-int8@1.0.1: {}
|
||||
|
||||
pg-pool@3.7.1(pg@8.13.3):
|
||||
dependencies:
|
||||
pg: 8.13.3
|
||||
|
||||
pg-protocol@1.7.1: {}
|
||||
|
||||
pg-types@2.2.0:
|
||||
dependencies:
|
||||
pg-int8: 1.0.1
|
||||
postgres-array: 2.0.0
|
||||
postgres-bytea: 1.0.0
|
||||
postgres-date: 1.0.7
|
||||
postgres-interval: 1.2.0
|
||||
|
||||
pg@8.13.3:
|
||||
dependencies:
|
||||
pg-connection-string: 2.7.0
|
||||
pg-pool: 3.7.1(pg@8.13.3)
|
||||
pg-protocol: 1.7.1
|
||||
pg-types: 2.2.0
|
||||
pgpass: 1.0.5
|
||||
optionalDependencies:
|
||||
pg-cloudflare: 1.1.1
|
||||
|
||||
pgpass@1.0.5:
|
||||
dependencies:
|
||||
split2: 4.2.0
|
||||
|
||||
postgres-array@2.0.0: {}
|
||||
|
||||
postgres-bytea@1.0.0: {}
|
||||
|
||||
postgres-date@1.0.7: {}
|
||||
|
||||
postgres-interval@1.2.0:
|
||||
dependencies:
|
||||
xtend: 4.0.2
|
||||
|
||||
prettier@3.2.5: {}
|
||||
|
||||
proxy-from-env@1.1.0: {}
|
||||
|
||||
split2@4.2.0: {}
|
||||
|
||||
ts-node@10.9.2(@types/node@22.10.2)(typescript@5.4.2):
|
||||
dependencies:
|
||||
'@cspotcode/source-map-support': 0.8.1
|
||||
|
@ -255,4 +372,6 @@ snapshots:
|
|||
|
||||
v8-compile-cache-lib@3.0.1: {}
|
||||
|
||||
xtend@4.0.2: {}
|
||||
|
||||
yn@3.1.1: {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue