Skip to content

Instantly share code, notes, and snippets.

@steffenr
Created December 8, 2023 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save steffenr/3f36990035f25d610fd2ac782a80d1d8 to your computer and use it in GitHub Desktop.
Save steffenr/3f36990035f25d610fd2ac782a80d1d8 to your computer and use it in GitHub Desktop.
Convert .po to .csv
#!/bin/bash
# Check if the required command-line argument is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <po_file>"
exit 1
fi
po_file="$1"
csv_file="${po_file%.po}.csv"
# Convert PO file to CSV using awk
awk -F '"' '/msgid/ {msg=$2} /msgstr/ {print "\""msg"\",\"" $2 "\""}' "$po_file" > "$csv_file"
echo "Conversion complete. CSV file: $csv_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment