Skip to content

Commit

Permalink
fix: fix language packs
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Aug 9, 2024
1 parent 6c9b2d4 commit 2c82b08
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rollup/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function isCallPure (file: string, functionName: string, node: recast.types.name
}

const nlsKeys: [moduleId: string, keys: string[]][] = []
let nlsIndex = -1
let nlsIndex = 0

function transformVSCodeCode (id: string, code: string) {
const translationPath = nodePath.relative(id.startsWith(OVERRIDE_PATH) ? OVERRIDE_PATH : VSCODE_SRC_DIR, id)
Expand Down Expand Up @@ -224,13 +224,13 @@ function transformVSCodeCode (id: string, code: string) {
throw new Error('Unable to extract translation key')
}

if (!moduleNlsKeys.includes(localizationKey)) {
moduleNlsKeys.push(localizationKey)
nlsIndex++
let moduleNlsIndex = moduleNlsKeys.indexOf(localizationKey)
if (moduleNlsIndex === -1) {
moduleNlsIndex = moduleNlsKeys.push(localizationKey) - 1
}
path.replace(recast.types.builders.callExpression(
path.node.callee,
[recast.types.builders.numericLiteral(nlsIndex), ...path.node.arguments.slice(1)]
[recast.types.builders.numericLiteral(nlsIndex + moduleNlsIndex), ...path.node.arguments.slice(1)]
))
transformed = true
} else if (node.callee.type === 'MemberExpression') {
Expand Down Expand Up @@ -318,6 +318,7 @@ function transformVSCodeCode (id: string, code: string) {

if (moduleNlsKeys.length > 0) {
nlsKeys.push([translationPath, moduleNlsKeys])
nlsIndex += moduleNlsKeys.length
}

return patchedCode
Expand Down

0 comments on commit 2c82b08

Please sign in to comment.