Skip to content

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

Description

@codeCraft-Ritik

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

  • wtfjs.js (Line 57–66)

Root Cause Analysis

In wtfjs.js:

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

$ 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:

--- 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("-");

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions