Created
December 29, 2021 15:25
-
-
Save peat-psuwit/a811a2714ae64a51a5a82b8dd140a516 to your computer and use it in GitHub Desktop.
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
# User: replace "system-update" below to your plugin of interest. | |
BEGIN { | |
plugin_name = "system-update" | |
plugin_pat = "/plugins/" plugin_name "/" | |
} | |
$0 ~ /^#\. TRANSLATORS: This is a keyword or name for the / { | |
if ($11 == plugin_name) { | |
has_keyword=1 | |
} | |
next | |
} | |
$1 == "#." { | |
stored_comment = stored_comment $0 "\n" | |
next | |
} | |
$0 ~ "^# [A-Za-z]+ translation for lomiri-system-settings" { | |
# Special case | |
$5 = "lomiri-system-settings-" plugin_name | |
# Fall-through | |
} | |
$0 == "# This file is distributed under the same license as the lomiri-system-settings package." { | |
# Special case | |
$12 = "lomiri-system-settings-" plugin_name | |
# Fall-through | |
} | |
$1 == "#" { | |
# Appear in the very first lines only. | |
need_translation = 1 | |
next | |
} | |
function print_comment_header() { | |
if (!comment_header_printed) { | |
printf "%s", stored_comment | |
stored_comment = "" | |
printf "#:" | |
comment_header_printed = 1 | |
need_translation = 1 | |
} | |
} | |
$1 == "#:" { | |
comment_header_printed=0 | |
# Skip the comment header | |
for(i=2; i<=NF; i++) { | |
if ($i ~ /settings.js:[0-9]+$/ && has_keyword) { | |
# We can't distinguish between different settings.js entries. | |
# Just print at least once; the re-genaration should fix the | |
# line numbers. | |
print_comment_header() | |
printf " %s", $i | |
has_keyword=0 | |
} | |
else if ( $i~plugin_pat ) { | |
print_comment_header() | |
printf " %s", $i | |
} | |
} | |
if (comment_header_printed) { | |
printf "\n" | |
} | |
next | |
} | |
$1 == "#," { | |
# No idea. | |
if (need_translation) print | |
next | |
} | |
$0 == "\"Project-Id-Version: lomiri-system-settings\\n\"" { | |
# Special case | |
print "\"Project-Id-Version: lomiri-system-settings-" plugin_name "\\n\"" | |
next | |
} | |
$1 ~ /^msg/ || $1 ~ "^\"" { | |
if (need_translation) print | |
next | |
} | |
/^$/ { | |
if (need_translation) { | |
print "" | |
} | |
stored_comment = "" | |
need_translation = 0 | |
next | |
} |
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
# User: replace "system-update" below to your plugin of interest. | |
BEGIN { | |
plugin_name = "system-update" | |
plugin_pat = "/plugins/" plugin_name "/" | |
} | |
$0 ~ /^#\. TRANSLATORS: This is a keyword or name for the / { | |
if ($11 != plugin_name) { | |
has_keyword=1 | |
} | |
next | |
} | |
$1 == "#." { | |
stored_comment = stored_comment $0 "\n" | |
next | |
} | |
$1 == "#" { | |
# Appear in the very first lines only. | |
need_translation = 1 | |
next | |
} | |
function print_comment_header() { | |
if (!comment_header_printed) { | |
printf "%s", stored_comment | |
stored_comment = "" | |
printf "#:" | |
comment_header_printed = 1 | |
need_translation = 1 | |
} | |
} | |
$1 == "#:" { | |
comment_header_printed=0 | |
# Skip the comment header | |
for(i=2; i<=NF; i++) { | |
if ($i ~ /settings.js:[0-9]+$/) { | |
# We can't distinguish between different settings.js entries. | |
# Because we don't want to change settings.js entries if it's | |
# unrelated to the removed plugin, print all of them. | |
if (has_keyword) { | |
print_comment_header() | |
printf " %s", $i | |
} | |
} | |
else if ( ! ($i~plugin_pat) ) { | |
print_comment_header() | |
printf " %s", $i | |
} | |
} | |
if (comment_header_printed) { | |
printf "\n" | |
} | |
next | |
} | |
$1 == "#," { | |
# No idea. | |
if (need_translation) print | |
next | |
} | |
$1 ~ /^msg/ || $1 ~ "^\"" { | |
if (need_translation) print | |
next | |
} | |
/^$/ { | |
if (need_translation) { | |
print "" | |
} | |
stored_comment = "" | |
has_keyword = 0 | |
need_translation = 0 | |
next | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment