blob: a8bfb5a0e37502c1eb7ca2bd9e8f722f38ec81c8 [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001#!/usr/bin/env ruby
2
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +01003MASTER="en-gb"
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01004
5DIR = "#{__dir__}/.."
6
7keys = %x[sed -r 's/.*(\\['.*'\\]\\['.*'\\]).*/\\1/g' #{DIR}/data/web/lang/lang.#{MASTER}.php | grep '^\\\[' | sed 's/\\[/\\\\[/g' | sed 's/\\]/\\\\]/g'|sort | uniq]
8
9not_used_in_php = []
10keys.split("\n").each do |key|
11 %x[git grep "#{key}" -- #{DIR}/data/web/*.php #{DIR}/data/web/inc #{DIR}/data/web/modals]
12 if $?.exitstatus > 0
13 not_used_in_php << key
14 end
15end
16
17# \['user'\]\['username'\]
18# \['user'\]\['waiting'\]
19# \['warning'\]\['spam_alias_temp_error'\]
20
21not_used = []
22not_used_in_php.each do |string|
23 section = string.scan(/([a-z]+)/)[0][0]
24 key = string.scan(/([a-z]+)/)[1][0]
25 %x[git grep lang.#{key} -- #{DIR}/data/web/js/#{section}.js #{DIR}/data/web/js/debug.js]
26 if $?.exitstatus > 0
27 not_used << string
28 end
29end
30
31puts "# Remove unused translation keys:"
32not_used.each do |key|
33 puts "sed -i \"/\\$lang#{key}.*;/d\" data/web/lang/lang.??.php"
34end