jshmrtn / vue3-gettext

Translate Vue 3 applications with gettext.
https://jshmrtn.github.io/vue3-gettext/
MIT License
66 stars 23 forks source link

Feature: Output a LINGUAS file during extraction step? #6

Closed olof-nord closed 2 years ago

olof-nord commented 2 years ago

This file is specified to contain the list of available translations.

More here: https://www.gnu.org/software/gettext/manual/html_node/po_002fLINGUAS.html

Additionally, the two messages.pot writeFileSync calls were removed. This file is added also when both calls are removed, and both calls errors out due to the "wx" flag failing if the path exists. Even when initially manually removing the file, this error occurs.

Lastly, the forEach iteration for the locales is replaced with a for of loop as the promise returned in the forEach is not used.

If adjusting the catch blocks to print out the error if caught, below message is shown.

try {
    fs.writeFileSync(potPath, "", { flag: "wx" });
} catch(error) {
    console.error(error);
}
Error: EEXIST: file already exists, open './dev/language/messages.pot'
    at Object.openSync (node:fs:585:3)
    at Object.writeFileSync (node:fs:2153:35)
    at /home/olof/git/vue3-gettext/scripts/gettext_extract.js:70:10
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  errno: -17,
  syscall: 'open',
  code: 'EEXIST',
  path: './dev/language/messages.pot'
}
lzurbriggen commented 2 years ago

@olof-nord I was not aware of the LINGUAS file. Seems to work fine, thank you!