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AX,IAA6B,gBAA7B,EAA+C;AAC7C,QAAA,MAAM,CAAC,IAAP,CAAY,cAAc,SAAS,IAAI,cAAK,cAAL,CAAoB,KAAK,kBAAkB,GAAlF;AACD;AACF;AACF;;AACD,SAAO,MAAP;AACD,C","sourcesContent":["import { asArray } from \"builder-util\"\nimport { bundledLanguages, langIdToName, lcid, toLangWithRegion } from \"../../util/langs\"\nimport _debug from \"debug\"\nimport { outputFile, readFile } from \"fs-extra\"\nimport { safeLoad } from \"js-yaml\"\nimport * as path from \"path\"\nimport { PlatformPackager } from \"../../platformPackager\"\nimport { NsisOptions } from \"./nsisOptions\"\nimport { NsisScriptGenerator } from \"./nsisScriptGenerator\"\nimport { nsisTemplatesDir } from \"./nsisUtil\"\n\nconst debug = _debug(\"electron-builder:nsis\")\n\nexport class LangConfigurator {\n readonly isMultiLang: boolean\n readonly langs: Array\n\n constructor(options: NsisOptions) {\n const rawList = options.installerLanguages\n\n if (options.unicode === false || rawList === null || (Array.isArray(rawList) && rawList.length === 0)) {\n this.isMultiLang = false\n }\n else {\n this.isMultiLang = options.multiLanguageInstaller !== false\n }\n\n if (this.isMultiLang) {\n this.langs = rawList == null ? bundledLanguages.slice() : asArray(rawList)\n .map(it => toLangWithRegion(it.replace(\"-\", \"_\")))\n }\n else {\n this.langs = [\"en_US\"]\n }\n }\n}\n\nexport function createAddLangsMacro(scriptGenerator: NsisScriptGenerator, langConfigurator: LangConfigurator) {\n const result: Array = []\n for (const langWithRegion of langConfigurator.langs) {\n let name: string\n if (langWithRegion === \"zh_CN\") {\n name = \"SimpChinese\"\n }\n else if (langWithRegion === \"zh_TW\") {\n name = \"TradChinese\"\n }\n else if (langWithRegion === \"nb_NO\") {\n name = \"Norwegian\"\n }\n else if (langWithRegion === \"pt_BR\") {\n name = \"PortugueseBR\"\n }\n else {\n const lang = langWithRegion.substring(0, langWithRegion.indexOf(\"_\"))\n name = (langIdToName as any)[lang]\n if (name == null) {\n throw new Error(`Language name is unknown for ${lang}`)\n }\n\n if (name === \"Spanish\") {\n name = \"SpanishInternational\"\n }\n }\n result.push(`!insertmacro MUI_LANGUAGE \"${name}\"`)\n }\n\n scriptGenerator.macro(\"addLangs\", result)\n}\n\nasync function writeCustomLangFile(data: string, packager: PlatformPackager) {\n const file = await packager.getTempFile(\"messages.nsh\")\n await outputFile(file, data)\n return file\n}\n\nexport async function addCustomMessageFileInclude(input: string, packager: PlatformPackager, scriptGenerator: NsisScriptGenerator, langConfigurator: LangConfigurator) {\n const data = safeLoad(await readFile(path.join(nsisTemplatesDir, input), \"utf-8\"))\n const instructions = computeCustomMessageTranslations(data, langConfigurator).join(\"\\n\")\n debug(instructions)\n scriptGenerator.include(await writeCustomLangFile(instructions, packager))\n}\n\nfunction computeCustomMessageTranslations(messages: any, langConfigurator: LangConfigurator): Array {\n const result: Array = []\n const includedLangs = new Set(langConfigurator.langs)\n for (const messageId of Object.keys(messages)) {\n const langToTranslations = messages[messageId]\n const unspecifiedLangs = new Set(langConfigurator.langs)\n for (const lang of Object.keys(langToTranslations)) {\n const langWithRegion = toLangWithRegion(lang)\n\n if (!includedLangs.has(langWithRegion)) {\n continue\n }\n\n const value = langToTranslations[lang]\n if (value == null) {\n throw new Error(`${messageId} not specified for ${lang}`)\n }\n\n result.push(`LangString ${messageId} ${lcid[langWithRegion]} \"${value.replace(/\\n/g, \"$\\\\r$\\\\n\")}\"`)\n unspecifiedLangs.delete(langWithRegion)\n }\n\n if (langConfigurator.isMultiLang) {\n const defaultTranslation = langToTranslations.en.replace(/\\n/g, \"$\\\\r$\\\\n\")\n for (const langWithRegion of unspecifiedLangs) {\n result.push(`LangString ${messageId} ${lcid[langWithRegion]} \"${defaultTranslation}\"`)\n }\n }\n }\n return result\n}"],"sourceRoot":""}