Perl script for copying a locale to all (or fewer) other locales

Tools which are useful for mod development.
Honktown
Smart Inserter
Smart Inserter
Posts: 1042
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Perl script for copying a locale to all (or fewer) other locales

Post by Honktown »

Wrote a script because I think people would get annoyed of "unknown key 'mymod-blah-blah'" appearing in my mod. It's better than no string showing up, but eventually you want to fill in actual locales if people help you or you try a translator.

https://drive.google.com/open?id=14C1jQ ... nShK0xOGrU

https://pastebin.com/KUf8hR7f

With no arguments:

Code: Select all

	Help:
		copy a locale folder to every other locale (or fewer)
		run in mod/ or mod/locale

		-L <locale> to use language (only 1!)
		-NL <locale> to ignore locale. can be used many times
		-W to overwrite existing locale files

		example: perl locale.pl -L pl -NL en -NL ja -W
			copy polish to every locale except english and japanese, overwrite existing files

		example with prints sent to file:
			perl locale.pl -L pl -NL en -NL ja -W > localecopy.txt 2>&1
with perl locale.pl -L en > output.txt 2>&1 if the folder "af" is missing:

Code: Select all

using locale: en
ran from mod folder
Copying ./locale/en/config.cfg to ./locale/af/

Copying ./locale/en/config.cfg to ./locale/ar/
./locale/ar/config.cfg exists and overwrite was not specified (-W)

Copying ./locale/en/config.cfg to ./locale/be/
./locale/be/config.cfg exists and overwrite was not specified (-W)

Copying ./locale/en/config.cfg to ./locale/bg/
./locale/bg/config.cfg exists and overwrite was not specified (-W)

Copying ./locale/en/config.cfg to ./locale/ca/
./locale/ca/config.cfg exists and overwrite was not specified (-W)
...
Using perl locale.pl -L en -W -NL af >localeout.txt 2>&1

Code: Select all

Removed locale af
using locale: en
ran from mod folder
Copying ./locale/en/config.cfg to ./locale/ar/

Copying ./locale/en/config.cfg to ./locale/be/

Copying ./locale/en/config.cfg to ./locale/bg/

Copying ./locale/en/config.cfg to ./locale/ca/
...
I have a Perl program on windows because I like it, but it's not common to have one. I could write a batch script for windows users, but I'm certain it wouldn't be as good.
I have mods! I guess!
Link
Post Reply

Return to “Development tools”