views:

212

answers:

1

How to use gettext in bash script?

I only found this page, but I don't understand it.

Localization

My script is written like this:

 #!/bin/bash
 . lang_file.sh
 echo $LANG_HELLO_WORLD

And lang_file.sh look like that:

 #!/bin/bash
 LANG_HELLO_WORLD="Hello World"

I want to change lang_file.sh to something using gettext, like this:

 #!/bin/bash
 LANG_HELLO_WORLD=`some gettext command to get string in user language`

I want to use the code in Launchpad, so other users can translate it (.po, .pot files)

Sorry for bad English, any suggestions?

+1  A: 

Try this tutorial to see if it's more helpful.

Dennis Williamson
Thank you!But I have next problem, this is bash script, and I don't want to install it somewhere in system.How I can make something like "lang" folder, and gettext will search there, not in /usr/share/locale ???
maxorq
@maxorq: I would imagine that you could set `TEXTDOMAINDIR=` to point anywhere you want.
Dennis Williamson
Yeah, but I can't get it to work.I try to set it to "./", "./lang" "./lang/pl/LC_MESSAGES", and others, but it just don't work.
maxorq
@maxorq: I'm assuming that you've created those directories and moved the `.mo` files into them?
Dennis Williamson
Of course yes, I'm not stupid so much!(but I am bit)
maxorq
@maxorq: I didn't intend to be insulting. I'm sorry if it sounded that way. It's just no good making assumptions so I over-verify sometimes.
Dennis Williamson
OK, sorry, but it still don't work and I still wait and wait for your next post, thinking that it will solve my problem.
maxorq
HEY !!!!!!!!!!!!
maxorq
PLEASE MY PROJECT CAN'T GO ON WITHOUT IT!!!
maxorq
oh thank you very much!!!
maxorq