Skip to content

Instantly share code, notes, and snippets.

@nasieti
Last active December 18, 2015 12:18
Show Gist options
  • Save nasieti/5781570 to your computer and use it in GitHub Desktop.
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)
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