2
0
forked from Wavyzz/dolibarr
Files
dolibarr-fork/dev/tools/fixduplicatelangkey.sh
MDW c885c6917e Qual: Ignore most shellcheck annotations, fix some (#27452)
# Qual: Ignore most shellcheck annotations, fix some

Most shellcheck annotations are ignored - this is to make sure that ci
can work for existing scripts.

Some fixes were applied.

pre-commit script was beautyfied by temporarily suppressing the IFS= expression on 2 lines.
2024-01-12 21:03:08 +01:00

42 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# Helps find duplicate translation keys in language files
#
# Copyright (C) 2014 Raphaël Doursenaud - rdoursenaud@gpcsolutions.fr
# shellcheck disable=2006,2035,2044,2061,2166,2268
# Syntax
if [ "x$1" != "xlist" -a "x$1" != "xfix" ]
then
echo "Detect duplicate translation keys inside a file (there is no cross file check)."
echo "Usage: detectduplicatelangkey.sh (list|fix)"
fi
if [ "x$1" = "xlist" ]
then
echo "Search duplicate keys into en_US lang files (there is no cross file check)"
for file in `find htdocs/langs/en_US -name *.lang -type f`
do
dupes=$(
sed "s/^\s*//" "$file" | # Remove any leading whitespace
sed "s/\s*\=/=/" | # Remove any whitespace before =
grep -Po "(^.*?)=" | # Non greedeely match everything before =
sed "s/\=//" | # Remove trailing = so we get the key
sort | uniq -d # Find duplicates
)
if [ -n "$dupes" ]
then
echo "Duplicates found in $file"
echo "$dupes"
fi
done
fi
# To convert
if [ "x$1" = "xfix" ]
then
echo Feature not implemented. Please fix files manually.
fi