armory3d / armory3d/armorpaint

extract_locales.js silently does nothing when run outside the repository root

Open Beginner friendly
#2,122 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
5k
Forks
553
Avg merge
3d 11h
Merged PRs (30d)
6

Description

**ArmorPaint version:**
git `0a125e50bb8602f565f8e4f258264dd745e76556` (main)

**OS / GPU model:**
Windows 10, x64 (uses the committed `base/tools/bin/windows_x64/amake.exe`). Not GPU or platform specific.

**Issue description:**

`base/tools/extract_locales.js` resolves its inputs relative to the current working directory:

```js
let locale_path = "./paint/assets/locale/" + locale + ".json";
let source_paths = [ "paint/sources", "paint/sources/nodes_material", ... ];
for (let path of source_paths) {
if (!fs_exists(path)) {
continue; // silently skips
}
...
}
fs_writefile(locale_path, ...);
```

Run from anywhere other than the repository root, every entry in `source_paths` is skipped. Nothing is extracted, nothing is reported, and the process still exits **0**. Because `locale_path` is relative too, the output directory normally does not exist at that location either, so no file is written - the command appears to have succeeded and produced no new locale.

This is easy to hit: `readme.md` tells you to `cd armorpaint/paint` for the build steps, then documents the locale command as `./base/make --js base/tools/extract_locales.js `, which only works from the repository root.

**Steps to reproduce:**

From a checkout, with the committed `amake` binary:

```bash
# works: extracts and rewrites the locale
cd
./base/tools/amake.exe base/tools/make.js --js base/tools/extract_locales.js zz
# exit 0, paint/assets/locale/zz.json written

# silently does nothing
cd paint
../base/tools/amake.exe ../base/tools/make.js --js ../base/tools/extract_locales.js zz
# exit 0, no output, no file written
```

Measured on a scratch tree containing `paint/sources/demo.c` with two `tr("...")` strings and an existing `paint/assets/locale/zz.json`:

| cwd | stdout | exit | `zz.json` |
|---|---|---|---|
| repository root | (none) | 0 | rewritten, translations preserved |
| `paint/` | (none) | 0 | not written |

The same scratch tree run from `paint/` with the source paths present produces the expected file, so the paths themselves are fine - only the cwd assumption is unguarded.

A `std.exit(1)` with a message here would make the failure visible instead of silent, following the existing `"Locale code not set!"` path at the top of the same file.

**Related observation (not part of this report):** all 13 locale files currently lag the sources - each has 662 keys against 800 extracted `tr()` strings, with 54 keys that no longer appear in any source file. Regenerating them is a translation workflow decision, so it is only noted here.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with base/tools/extract_locales.js, especially its relative locale_path and source_paths handling and the existing "Locale code not set!" error path. Reproduce the command from the repository root and from paint/ using the committed amake binary. Done means the out-of-root invocation no longer silently succeeds without extraction, while the repository-root invocation continues to rewrite the locale.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.