Difference between revisions of "TranslatorShellscript"

From The Battle for Wesnoth Wiki
(Category: Translation)
Line 50: Line 50:
  
 
== Comments (nice ones only) ==
 
== Comments (nice ones only) ==
 +
 +
 +
[[Category:Translations]]

Revision as of 11:59, 25 February 2009

Disclaimer: This scripts are far away from "flawless". Anyhow, try it, like it, use it; dislike it, improve it :).

And, yes, I know, its programming is pathetic :). And, yes, more knowledge about WML would definitely improve it. Or a higher frustration threshold... :). Or the accuracy, a real programmer would have (and test it with more than one po-file in one language only). Hence, improvements might be a very good idea - If anybody has suggestions, feel free to contact me.

Feel free to post improvements as well. In which languages it does not work at all? What kind of shell script would are needed as well?

Or even realize them on a higher level - why not writing a script to transform it in TEX - per aspera ad astra :).

Thanks to the programmer(s) that included the "speaker" in the comments of the po-files (Ivanovic?)! Those are definitely helpful and make this approach possible.

First of all

Prior to use the shell scripts, the po-File needs to be opened and saved with poEdit. Then the texts are saved in separated lines without interfering /n's.

Extracting a target language script

For proof-reading of a campaign it might be much easier to print it out in a more "scriptlike" format (<charactername>: <text>) (target language only), e.g. to read it in a bus, a train or in a car.

I load this textfile into a editor to print it in two columns with the name of the "speaker" intended (like in script book).

>cat ./de.po | grep -v "msgid \"" | grep -v "#: data" | sed "s/\[message\]: speaker//g" | sed "s/#. =//g" | sed "s/msgstr/:/g" |grep -v ": \"\"" | sed ':;s/\n:/:/;N;T' | sed ':;s/\n\n/\n/;N;T'| sed "s/#. \[scenario\]/\n#. \[scenario\]/g" > target-language-script.txt

Extracting an English script

For proof-reading of a campaign it might be much easier to print it out in a more "scriptlike" format (<charactername>: <text>) (english only), e.g. to read it in a bus. This one is even more preliminary than the one before. It still contains some target language parts.

>cat de.po | grep -v "msgstr \"" | grep -v "#: data" | sed "s/\[message\]: speaker//g" | sed "s/#. =//g" | sed "s/msgid/:/g" |grep -v ": \"\"" | sed ':;s/\n:/:/;N;T' | sed ':;s/\n\n/\n/;N;T'| sed "s/#. \[scenario\]/\n#. \[scenario\]/g" > english.txt

Extracting a list of charcters

using the command line

Be aware, that you should be in the right directory. It contains *.cfg files for each campaign-scenaio.

> cd <wesnoth-installpath>/data/campaigns/Northern_Rebirth/scenarios
>cat *.cfg | grep "description=" | grep -v "_" | sed 's/^[ \t]*//;s/[ \t]*$//' | sort |uniq -c | sort -nr > ~/NRcharacterlist.txt

using a shell script

save the following as script, e.g. named "extChar.sh". Use it within the correct directory (see above) with the target file as option. Use "chmod" to make it executable.


#bash
# extract characters/personnames from wesnoth cfg files
cat *.cfg | grep "description=" | grep -v "_" | sed 's/^[ \t]*//;s/[ \t]*$//' | sort |uniq -c | sort -nr > ~/Desktop/$1

step 2 - if you want to have the characters list only

>cat NRcharacterlist.txt | cut -d '=' -f 2

Comments (nice ones only)