I wrote very simple UNIX shell script that finds such messages. I
f you have a bad luck (like me) to work on Windows, do not worry. You can always run it using Cygwin (as I do).
I work in Java, so script searches for *.java and *.jsp files. But it can be easily modified.
#!/bin/sh
###########################################################
# This script searches source code for unesed strings and prints them.
# It assumes that strings are stored properties files and code is in *.java or *.jsp files.
###########################################################
# This script searches source code for unesed strings and prints them.
# It assumes that strings are stored properties files and code is in *.java or *.jsp files.
###########################################################
if [ "$#" -ne 2 ]; then
echo Usage: $0 RESOURCE_FILES_PATTERN SRC_CODE_ROOT_DIRECTORY
echo e.g. $0 “MyProject/resources/Messages*.properties” “MyProject/src”
exit 0;
fi
echo Usage: $0 RESOURCE_FILES_PATTERN SRC_CODE_ROOT_DIRECTORY
echo e.g. $0 “MyProject/resources/Messages*.properties” “MyProject/src”
exit 0;
fi
texts=$1
src=$2
src=$2
for line in `(ls $texts | while read file; do cat $file; done;) | sed ‘s/#.*//’ | sed ‘s/=.*//’ | sed ‘s/ //’ | egrep -v “^$” | sort -u`; do
found=false
for file in `find $src -name *.java -or -name *.jsp`; do
grep “\”$line\”" $file >/dev/null
if [ "$?" == "0" ]; then
found=true
continue
fi
done;
if [ $found == false ]; then
echo $line is not found
fi
done;
for file in `find $src -name *.java -or -name *.jsp`; do
grep “\”$line\”" $file >/dev/null
if [ "$?" == "0" ]; then
found=true
continue
fi
done;
if [ $found == false ]; then
echo $line is not found
fi
done;
This post was previously published at alexr.blog.com
Hi Alex! To better localize strings, I would suggest trying an online localization tool like https://poeditor.com/. It has an intuitive and friendly design, useful features such as automatic translation, API, GitHub integration, making the localization process smoother for users. Maybe it is useful.
ReplyDelete