Skip to content

Instantly share code, notes, and snippets.

@mondeja
Last active September 23, 2022 21:46
Show Gist options
  • Save mondeja/3cbcaee52345775f434d4208d571e76e to your computer and use it in GitHub Desktop.
Save mondeja/3cbcaee52345775f434d4208d571e76e to your computer and use it in GitHub Desktop.
txt2po
#!/bin/sh
output=""
while read line; do
if [ -z "$line" ]; then
continue
fi;
escaped_line=$(echo $line | sed -e 's/"/\\"/g')
new_line="msgid \"$escaped_line\"\nmsgstr \"\""
if [ -n "$output" ]; then
output="${output}\n\n${new_line}"
else
output="${output}${new_line}"
fi;
done < $1
echo "$output" > $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment