Skip to content

Commit

Permalink
Ran npm format for convertConfig
Browse files Browse the repository at this point in the history
Issue #676
  • Loading branch information
Christopher-Shiu committed Nov 18, 2024
1 parent 3a3cb76 commit 6133d06
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions convert/convertConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,14 @@ function convertConfig(dataDir: string, verbose: number) {
(bc) => bc.books.filter((b) => b.type === 'glossary').length > 0
).length > 0;
}
if(isDictionaryConfig(data)){
const writingSystems: {[key: string] : DictionaryWritingSystemConfig} = {};
const writingSystemsTag = document.getElementsByTagName('writing-systems')[0];
if (isDictionaryConfig(data)) {
const writingSystems: { [key: string]: DictionaryWritingSystemConfig } = {};
const writingSystemsTag = document.getElementsByTagName('writing-systems')[0];
const writingSystemTags = writingSystemsTag.getElementsByTagName('writing-system');
for(const tag of writingSystemTags){
const writingSystem = parseDictionaryWritingSystem(tag, verbose);
const code : string = tag.attributes.getNamedItem('code')!.value;
writingSystems[code] = writingSystem;
for (const tag of writingSystemTags) {
const writingSystem = parseDictionaryWritingSystem(tag, verbose);
const code: string = tag.attributes.getNamedItem('code')!.value;
writingSystems[code] = writingSystem;
}

data.writingSystems = writingSystems;
Expand Down Expand Up @@ -664,11 +664,7 @@ function parseBookCollections(document: Document, verbose: number) {
return bookCollections;
}

function parseInterfaceLanguages(
document: Document,
data: AppConfig,
verbose: number
) {
function parseInterfaceLanguages(document: Document, data: AppConfig, verbose: number) {
const interfaceLanguagesTag = document.getElementsByTagName('interface-languages')[0];
const useSystemLanguage = parseTrait(interfaceLanguagesTag, 'use-system-language') === 'true';
const interfaceLanguages: {
Expand All @@ -681,10 +677,10 @@ function parseInterfaceLanguages(
.getElementsByTagName('writing-system');

for (const tag of writingSystemsTags) {
const code : string = tag.attributes.getNamedItem('code')!.value;
const code: string = tag.attributes.getNamedItem('code')!.value;
const writingSystem = parseWritingSystem(tag, verbose);
interfaceLanguages.writingSystems[code] = writingSystem;

if (verbose >= 2) {
console.log(`.. writing system ${code}`);
}
Expand All @@ -696,8 +692,7 @@ function parseInterfaceLanguages(
return interfaceLanguages;
}

function parseWritingSystem (element: Element, verbose: number) : WritingSystemConfig
{
function parseWritingSystem(element: Element, verbose: number): WritingSystemConfig {
const type = element.attributes.getNamedItem('type')!.value;
const fontFamily = element.getElementsByTagName('font-family')[0].innerHTML;
const textDirection = parseTrait(element, 'text-direction');
Expand All @@ -712,7 +707,7 @@ function parseWritingSystem (element: Element, verbose: number) : WritingSystemC
textDirection,
displayNames
};

return writingSystem;
}
function parseDictionaryWritingSystem(
Expand All @@ -729,9 +724,9 @@ function parseDictionaryWritingSystem(
const ignoreChars = ignoreCharsTag
? ignoreCharsTag.textContent?.split(/\s+/).filter((char) => char)
: undefined;
sortMethod = { type: type || "default", ignoreChars };
sortMethod = { type: type || 'default', ignoreChars };
} else {
sortMethod = { type: "default" };
sortMethod = { type: 'default' };
}

let alphabet: string[] | undefined;
Expand All @@ -743,9 +738,7 @@ function parseDictionaryWritingSystem(
let inputButtons: string[] | undefined;
const inputButtonsTag = element.getElementsByTagName('input-buttons')[0];
if (inputButtonsTag) {
inputButtons = inputButtonsTag.textContent
?.split(/\s+/)
.filter((button) => button);
inputButtons = inputButtonsTag.textContent?.split(/\s+/).filter((button) => button);
}

// Parse the features
Expand Down Expand Up @@ -773,11 +766,10 @@ function parseDictionaryWritingSystem(
alphabet,
inputButtons,
features,
reversalFilename,
reversalFilename
};
}


function parseMenuLocalizations(document: Document, verbose: number) {
const translationMappingsTags = document.getElementsByTagName('translation-mappings');
let translationMappings: {
Expand Down

0 comments on commit 6133d06

Please sign in to comment.