Last active
December 18, 2015 12:18
-
-
Save nasieti/5781570 to your computer and use it in GitHub Desktop.
Fork a Joomla! extension XML file into a language INI file (#perl oneliner)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. backup - it may be destructive if you hate perl. | |
2. review - it does not catch all strings | |
# export strings for labels and descriptions | |
perl -ne '$p="PREFIX"; if (/name="(.*?)".*label="(.*?)".*description="(.+?)"/) { $n="\U$1"; $l=$2; $ll=$p."_$n"."_LBL"; $d=$3; $dd=$p."_$n"."_DESC"; s~$l~$ll~; s~$d~$dd~; print "$ll=\"$l\"\n$dd=\"$d\"\n"; }' extension.xml > translation.ini | |
# replace them with placeholders | |
perl -i -pe '$p="PREFIX"; if (/name="(.*?)".*label="(.*?)".*description="(.+?)"/) { $n="\U$1"; $l=$2; $ll=$p."_$n"."_LBL"; $d=$3; $dd=$p."_$n"."_DESC"; s~$l~$ll~; s~$d~$dd~; }' extension.xml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment