1
0

refresh locales after any change, not just a version update

This commit is contained in:
Hazelnoot
2024-10-15 12:23:18 -04:00
parent 45974a53f8
commit 652cc8602c
8 changed files with 41 additions and 31 deletions
+14
View File
@@ -0,0 +1,14 @@
import { createHash } from 'crypto';
import locales from './index.js';
// MD5 is acceptable because we don't need cryptographic security.
const hash = createHash('md5');
// Derive the version hash from locale content exclusively.
// This avoids the problem of "stuck" translations after modifying locale files.
const localesText = JSON.stringify(locales);
hash.update(localesText, 'utf8');
// We can't use regular base64 since this becomes part of a filename.
// Base64URL avoids special characters that would cause an issue.
export const localesVersion = hash.digest().toString('base64url');