-
Notifications
You must be signed in to change notification settings - Fork 806
/
remove-suffix.sh
executable file
·26 lines (21 loc) · 1.03 KB
/
remove-suffix.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
# This script modifies the *.po files, removing some chosen suffix
# from the msgstr of the given msgid. Use this if you removed e.g. a
# suffixing colon ":" from the original string in the source code
# (i.e. the msgid), and now for simplicity you want to remove them
# from all translations as well.
# Example: Say you changed the string from "Start Date:" to "Start
# Date" in the source. Now: 1. Create the most up-to-date template pot
# file using "make pot". 2. Update all po files using
# msgmerge. 3. Call this script as follows:
# ./remove-suffix.sh Start Date
# This will modify all *.po files in-place, removing the suffixing
# colon in the translations.
# Use all command line arguments as the single msgid string
MSGID="$@"
# Optionally change the suffix you want to remove here
REMOVED_SUFFIX=":"
for PO in *.po ; do
# echo perl -p0 -i -e"s^#, fuzzy\\n(msgid \"${MSGID}\"\\nmsgstr \".*)${REMOVED_SUFFIX}\"^\$1\"^" $PO
perl -p0 -i -e"s^#, fuzzy\\n(msgid \"${MSGID}\"\\nmsgstr \".*)${REMOVED_SUFFIX}\"^\$1\"^" $PO
done