A library that brings gettext support to Nushell!
There are three commands, tregister, _, and tprint. First you must register your path and program name with tregister like so:
tregister /usr/share/locale/ my-programThen you can start using tprint like so:
tprint "Hello World! I am {name}. I am {years} years old" { name: "Elsie", years: 19 }Or if you need to get the translated string alone:
let my_var = (_ "Hello {world}" { world: "World" })I also have provided the tool xnutext, not too disimilar to xgettext, which will extract all translatable strings from your nu programs. There are two catches to using this:
- Nutext must be installed and functional.
- Your program must be syntactically correct according to Nu:
xnutextwill not extract text if the program cannot be ran. This is becausexnutextrelies on Nu's AST capabilities to accurately know where commands are being run (as opposed to say, a string that contains_).
After you have verified these, you should run:
xnutext list of files -o po/program.pot