An open API service indexing awesome lists of open source software.

https://github.com/rhino-linux/nu_plugin_nutext


https://github.com/rhino-linux/nu_plugin_nutext

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# nutext
A library that brings gettext support to Nushell!

## Usage
There are three commands, `tregister`, `_`, and `tprint`. First you must register your path and program name with `tregister` like so:

```bash
tregister /usr/share/locale/ my-program
```

Then you can start using `tprint` like so:

```bash
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:

```bash
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:

1. Nutext must be installed and functional.
2. Your program must be syntactically correct according to Nu: `xnutext` will not extract text if the program cannot be ran. This is because `xnutext` relies 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:

```bash
xnutext list of files -o po/program.pot
```