Skip to content

Commit c306fb5

Browse files
committed
Update utils/localization/generate-images
1 parent db08613 commit c306fb5

File tree

4 files changed

+740
-233
lines changed

4 files changed

+740
-233
lines changed

utils/localization/generate-images/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
This tool can be used to automatically generate compressed main menu images for all locales.
44

5+
## Requirements
6+
7+
- [Inter font](https://rsms.me/inter/)
8+
- [Chrome browser](https://www.google.com/chrome/)
9+
- [Node.JS](https://nodejs.org/en/download)
10+
511
## Usage
612

713
1. Run `git checkout l10n/master` to switch to the current Crowdin sync branch so you're working with the latest pending locales (make sure the branch is up to date with `git pull`)
814
2. Run `cd utils/localization/generate-images`
915
3. Run `npm ci` to install npm dependencies
10-
4. Run `npm start` to start the generator
11-
5. Run `git status` to confirm that all updated images have now been generated in the `/Shared/data/MTA San Andreas/MTA/locale` directory
12-
6. Commit the updated image files into the `l10n/master` branch
16+
4. Open `node_modules/@squoosh/lib/index.js` and remove `globalThis.navigator={hardwareConcurrency:os.cpus().length};` on line 30
17+
5. Run `npm start` to start the generator
18+
6. Run `git status` to confirm that all updated images have now been generated in the `/Shared/data/MTA San Andreas/MTA/locale` directory
19+
7. Commit the updated image files into the `l10n/master` branch

utils/localization/generate-images/index.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import 'chromedriver';
3535
import {Browser, Builder} from 'selenium-webdriver';
3636
import chrome from 'selenium-webdriver/chrome.js';
3737

38-
const driver = new Builder().forBrowser(Browser.CHROME).setChromeOptions(new chrome.Options().headless()).build();
38+
// https://www.selenium.dev/blog/2023/headless-is-going-away/
39+
const driver = new Builder().forBrowser(Browser.CHROME).setChromeOptions(new chrome.Options().addArguments('--headless=new')).build();
3940

4041
await (async () => {
4142
try {
@@ -95,7 +96,8 @@ await (async () => {
9596
.map(dirent => dirent.name);
9697

9798
await Promise.allSettled(pngs.map(async (filename) => {
98-
const image = imagePool.ingestImage(`uncompressed/${locale}/${filename}`);
99+
const file = await fs.readFile(`uncompressed/${locale}/${filename}`);
100+
const image = imagePool.ingestImage(file);
99101

100102
try {
101103
await image.preprocess({ quant: { dither: 0.1, numColors: 8 } });

0 commit comments

Comments
 (0)