Theme Localization problem with yarn pot

Oh. Also, I guess I neglected that I’ve installed gettext via Homebrew and manually symlinked the path to the binaries. So similar to the post you quoted above, brew install gettext and then add export PATH="/usr/local/opt/gettext/bin:$PATH" to your run commands.

5 Likes

Ok, thanks a lot! I installed gettext now via Homebrew.

What does it mean to add this to my “run commands”? I should just execute it once in the terminal in my theme folder? I’m sorry if the question is dumb, I am not a professional developer and just learning all of this.

EDIT:

It worked! Thank you very much @knowler!

I would love to contribute by doing a pull request with the fix, but as I have never done this before, I’m not sure it will turn out to be correct. I will do my best.

2 Likes

Hey, no problem at all, we’re all learning — I don’t know if I’m doing it the best way haha. Do you know what shell you are using? If it’s the default — bash — then you can add it in ~/.bash_profile:

# Maybe near the top
export PATH="/usr/local/opt/gettext/bin:$PATH"
1 Like

Thanks for the kind words! Yes, it was the default, and actually homebrew provided a simple way to do what you said:

echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile

I think this gets the job done in the same way.

EDIT:

Created a pull request for single quotes and a notice here

1 Like

Any advice how I could run this script on windows?

I installed coreutils, findutils, gettext, and added it to .bash_profile, but I still get the error

xargs: xgettext: No such file or directory

I also added

"pot": "mkdir -p ./resources/lang && find ./resources ./app -iname '*.php' | xargs xgettext --add-comments=TRANSLATORS --force-po --from-code=UTF-8 --default-domain=de_DE -k__ -k_e -k_n:1,2 -k_x:1,2c -k_ex:1,2c -k_nx:4c,12 -kesc_attr__ -kesc_attr_e -kesc_attr_x:1,2c -kesc_html__ -kesc_html_e -kesc_html_x:1,2c -k_n_noop:1,2 -k_nx_noop:3c,1,2, -k__ngettext_noop:1,2 -o resources/lang/sage.pot && find ./resources -iname '*.blade.php' | xargs xgettext --language=Python --add-comments=TRANSLATORS --force-po --from-code=UTF-8 --default-domain=de_DE -k__ -k_e -k_n:1,2 -k_x:1,2c -k_ex:1,2c -k_nx:4c,12 -kesc_attr__ -kesc_attr_e -kesc_attr_x:1,2c -kesc_html__ -kesc_html_e -kesc_html_x:1,2c -k_n_noop:1,2 -k_nx_noop:3c,1,2, -k__ngettext_noop:1,2 -j -o resources/lang/sage.pot"

to my package.json

@strarsis Does one execute this command in the theme folder? Or just generally on mac? When I try to execute the command in my mac’s home folder or in my theme folder I get:

sudo: apt-get: command not found

apt-get is not going to exist for you on mac… Have you looked into what you need to do to install the utilities for macOS?

Search Google for “xgettext macos”

Yes I installed coreutils, findutils and gettext via brew with the instructions in this topic.

$ brew install coreutils && brew install findutils && brew install gettext

And then

$ echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile

Then in my theme directory

$ yarn pot

UPDATE: I tried $ yarn pot in another project, and it worked straight away… also tried it on the project I tried to translate in the first place, and it works!

1 Like

You might have just needed to reload your terminal.

2 Likes

Did you finely made it on windows ?
I still have an error “The syntax of the command is incorrect” even after installing coreutils, findutils and gettext

Thanks

No, I’m using Polylang so it wasn’t necessary. But in the long run I’ll setup Hackintosh because there is just too much trouble with Roots and windows or web dev in general.

Thanks for yout feedback.
Well, any help from the community would be appreciated to make it work on windows :slight_smile:

I’m getting the same error message on WSL:
xargs: xgettext: No such file or directory

Now I don’t really know my way around Linux but this seems to work:

I noticed that:
/usr/local/opt/gettext/bin
Doesn’t exist on my Ubuntu 18.04 WSL Installation. In fact, there is no ‘/opt/’ directory at all.

The closest thing folder I could find is here:
/home/linuxbrew/.linuxbrew/Cellar/gettext/0.19.8.1_1/bin

So I ran this command instead of the above PATH command:
echo ‘export PATH="/home/linuxbrew/.linuxbrew/Cellar/gettext/0.19.8.1_1/bin:$PATH"’ >> ~/.bash_profile
And then restarted the WSL terminal.

Now yarn pot seems to run fine, asides from a couple of ‘unterminated string’ warnings in my blade files.

It’s probably not a great solution so if anyone can figure out why I don’t have ‘/opt/gettext/bin/’ then please let me know.

2 Likes

I’m running into the same issue on Windows. Yarn pot script fails with an exit code 1 (Incorrect syntax).

Any help would be greatly appreciated. Thanks.

For me, this still returns

xargs: xgettext: No such file or directory
error Command failed with exit code 127.

Any help appreciated.

ps: tried

echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.zshrc

(using oh my zsh)

and reloading, it works.

Hi, I’m on Windows and I do have the same problem.
Did you find a solution ?

I use WSL 2 now, hence all *nix/Ubuntu tools can be used.