guillaumepotier / gettext.js

gettext.js is a lightweight yet complete and accurate GNU gettext port for node and the browser.
http://guillaumepotier.github.io/gettext.js
147 stars 48 forks source link

more complete port of gettext #78

Open slalomzacharyd opened 1 year ago

slalomzacharyd commented 1 year ago

Hello, I'm going to be starting to gettext-cli package to try to do a more complete javascript port of gettext. The only real translation game in town is i18next besides gettext, and I would like to enable the FE ecosystem to have a full set of native js tools if they are afraid of installing the C implemented gettext.

As it is right now, gettext is a bit of a hodgepodge for the node-js ecosystem holding it back. Do you have any interest in joining forces? I already have a set of packages for implementing xgettext, msgmerge and msgformat (output to json.) They all have 100% code coverage as well. I'm just going to make sure to migrate them to tyepscript before making new releases using them.

guillaumepotier commented 1 year ago

Hi @slalomzacharyd,

I dug a little bit the i18n world a few years ago for @wisembly, convinced that gettext and the po format (+ the free open source PoEdit sofware) was a really good creation and could benefit the web ecosystem and mainly our project.

I created a while back https://github.com/Wisembly/xgettext-php, a PoEdit parser in php (back then it was my predilection language) to extract our translations from ou .html, .js(x) files.

Then, I was obsessed by frontend package size and found the cool kids too heavy and not perfectly gettext compliant. Thus was born gettext.js

That being said, I might be interrested to have a glance at your project, and also feel free to help yourself from gettext.js piece of code if some are useful to you, but I'm afraid I won't have much time for that matter.

Hope you the best in your project

zakkudo commented 1 year ago

No worries. I'm looking for something a bit more complete for FE and node development.

For extraction these are my tenants:

  1. I don't believe any implementations give a cli similar to the real xgettext/msgmerge/msgiinit/gettext.
  2. It should allow a "watch command" for integration with bundlers (webpack/esbuild/rollup).
  3. It should have the ability to split the generated JSON translation files per module. This helps to only load the translation for the current page.
  4. It should use PO for the core because there is great software for editing PO files.
  5. Gettext should be minimal so it an be used on both the FE and BE with minimal bloating.
  6. It should be built on typescript so the definitions are built in and it is easier to get help from other developers.
  7. The extractor should be language antagonistic where possible as long as the function calls are C-like. There should not be an AST or parser per langauge.
zakkudo commented 1 year ago

I have done about half the work of transforming my base libraries to TS. it's probably going to be a few weeks before I make a release. I'm going to then attempt to do small incremental improvements. (I have a lot of my own stuff going on as well, and I'm hoping to put this mostly into maintenance mode when I can.)

zakkudo commented 1 year ago

(Sorry, This is my personal account instead of my work one.)

zakkudo commented 1 year ago

The current placeholder for the library is here: https://www.npmjs.com/package/gettext-cli. Please feel free to close this issue whenever you want. I don't want to get too spammy here.