mirror of
https://github.com/microsoft/vscode.git
synced 2026-10-01 11:32:08 +01:00
nls: precompute translation cache identity during packaging Stamp the commit and NLS table fingerprint in product metadata and pass it through bootstrap. Reuse cached translations without reading or hashing default tables, while isolating different target tables and preserving legacy product compatibility. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
19 lines
794 B
TypeScript
19 lines
794 B
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { createHash } from 'crypto';
|
|
import { readFileSync } from 'fs';
|
|
import { join } from 'path';
|
|
|
|
export function computeNLSMetadataHash(nlsMetadataPath: string, commit: string | undefined): string {
|
|
return createHash('sha256')
|
|
.update(commit ?? '')
|
|
.update('\0')
|
|
.update(readFileSync(join(nlsMetadataPath, 'nls.keys.json')))
|
|
.update('\0')
|
|
.update(readFileSync(join(nlsMetadataPath, 'nls.messages.json')))
|
|
.digest('hex');
|
|
}
|