#354·wtfjs

Language flag (`--lang`) fails on case-sensitive filesystems due to uppercase subtag mapping

Author: codeCraft-RitikCreated Sep 14, 2026Updated Sep 14, 2026

Issue : Language flag (--lang) fails on case-sensitive filesystems due to uppercase subtag mapping

Severity & Impact

  • Severity: High
  • Impact: All non-English translation manuals fail to load on Linux, Docker, and case-sensitive macOS/FreeBSD installations. Even the exact example printed in the tool's own --help output (wtfjs --lang pt-br) fails with an error stating the translation does not exist.

Affected File

Root Cause Analysis

In wtfjs.js:

javascript
const lang = (cli.flags.lang || "")
  .toLowerCase()
  .split("-")
  .map((l, i) => (i === 0 ? l : l.toUpperCase()))
  .join("-");

const translation = join(
  __dirname,
  !lang ? "./README.md" : `./README-${lang}.md`
);

The mapping .map((l, i) => (i === 0 ? l : l.toUpperCase())) converts language subtags into uppercase region codes (e.g. pt-br $\to$ pt-BR, zh-cn $\to$ zh-CN, fr-fr $\to$ fr-FR).

However, all translation files in the repository are named strictly in all lowercase:

  • README-pt-br.md
  • README-zh-cn.md
  • README-fr-fr.md
  • README-it-it.md
  • README-pl-pl.md
  • README-kr.md
  • README-si.md
  • README-hi.md

On case-sensitive filesystems (standard on Linux servers and CI runners), fs.stat("./README-pt-BR.md") returns ENOENT because Linux does not recognize README-pt-BR.md as README-pt-br.md.

Minimal Reproducible Example

bash
$ wtfjs --lang pt-br

Actual Output

The pt-BR translation does not exist

Expected Output

The Brazilian Portuguese translation (README-pt-br.md) opens in the pager.

Proposed Fix

Keep the language parameter lowercase so it matches the files on disk:

diff
--- a/wtfjs.js
+++ b/wtfjs.js
@@ -57,5 +57,2 @@
 const lang = (cli.flags.lang || "")
   .toLowerCase()
-  .split("-")
-  .map((l, i) => (i === 0 ? l : l.toUpperCase()))
-  .join("-");