Skip to content

Commit

Permalink
document not nls
Browse files Browse the repository at this point in the history
  • Loading branch information
shidel committed Jun 23, 2020
1 parent 769c251 commit 599c413
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 16 deletions.
125 changes: 110 additions & 15 deletions checkup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,70 @@ function script_help () {

}

function get_stamp () {
stat -f%m "${*}" 2>/dev/null
if [[ $? -ne 0 ]] ; then
echo 0
return 1
fi
return 0
}

function load_nls () {

unset ${1}
[[ "${2}" != "${EN}" ]] && return 0
local line flag hold t
hold=$( while [[ ! $flag ]] ; do
read -r line || flag=done
line="${line//[$'\t\r\n']}"
line="${line#${line%%[![:space:]]*}}"
line="${line%${line##*[![:space:]]}}"
t="${line}"
line="${line%%:*}"
line="${line%%=*}"
[[ "${line}" == "" ]] && continue
[[ "${t}" == "${line}" ]] && continue
line="${line%${line##*[![:space:]]}}"
[[ "${line// }" != "${line}" ]] && continue
[[ "${line:0:1}" == "#" ]] && continue
[[ "${line:0:1}" == ";" ]] && continue
echo "${line};"
done< "${2}" | sort )
hold="${hold//[$'\t\r\n']}"
if [[ "${hold}" != "" ]] ; then
echo "${hold}"
read -r ${1} <<<";${hold}"
elif [[ "${2}" != "${EN}" ]] ; then
EN_DATA="${EN}"
fi
}
function compare_nls () {
local t
local p="${1%/*}"
p="${p##*/}"
local EN_CMP=''
if [[ ${EN_STAMP} -eq 0 ]] ; then
EN_CMP='?'
elif [[ "${p}" == "nls" ]] ; then
[[ "${EN_DATA}" == "" ]] && load_nls EN_DATA "${EN}"
unset NLS_DATA
load_nls NLS_DATA "${i}"
else
UC=yes
fi
if [[ "${EN_CMP}" == "" ]] ; then
t=$(get_stamp "${1}")
[[ ${t} -lt ${EN_STAMP} ]] && EN_CMP='*'
fi
return 0
}
function lang_of_nls () {
local t=$(echo "${1}" | tr "[:upper:]" "[:lower:]")
Expand All @@ -27,15 +91,23 @@ function lang_of_nls () {
function calc_add_language () {
[[ "${1}" == "" ]] && return 0
local i="${1}"
local x="${i//\*}"
x="${x//!}"
x="${x//\?}"
[[ "${x}" == "" ]] && return 0
[[ "${LANGUAGES}" = '' ]] && LANGUAGES=";"
[[ "${APPLANGS}" = '' ]] && APPLANGS=";"
if [[ "${LANGUAGES//;${1};}" == "${LANGUAGES}" ]] ; then
LANGUAGES="${LANGUAGES}${1};"
if [[ "${LANGUAGES//;${x};}" == "${LANGUAGES}" ]] ; then
LANGUAGES="${LANGUAGES}${x};"
(( LANGS++ ))
fi
if [[ "${APPLANGS//;${1};}" == "${APPLANGS}" ]] ; then
APPLANGS="${APPLANGS}${1};"
if [[ "${APPLANGS//;${i};}" == "${APPLANGS}" ]] && \
[[ "${APPLANGS//;${i}\*;}" == "${APPLANGS}" ]] && \
[[ "${APPLANGS//;${i}\?;}" == "${APPLANGS}" ]] && \
[[ "${APPLANGS//;${i}!;}" == "${APPLANGS}" ]] \
; then
APPLANGS="${APPLANGS}${i};"
fi
}
Expand All @@ -44,13 +116,31 @@ function calc_dir_languages () {
[[ ! -d "${1}" ]] && return 1
local i utf l
unset EN
unset EN_STAMP
unset EN_DATA
for i in "${1}"/* ; do
[[ ! -e "${i}" ]] && continue
if [[ "${EN}" == "" ]] ; then
EN="${1}/${1%%/*}.en"
if [[ ! -e "${EN}" ]] ; then
l=$(ls -a1d "${1}"/*.en 2>/dev/null | wc -l )
[[ ${l} -eq 1 ]] && EN=$(ls -a1d "${1}"/*.en)
fi
EN_STAMP=$(get_stamp "${EN}")
[[ ! -e "${EN}" ]] && UC=fail
fi
utf=$(ls -1d "${i}"* 2>/dev/null | grep -i "${i}\.utf-8" )
[[ "${utf}" != "" ]] && continue
l=$(lang_of_nls "${i}")
[[ "${l}" == "" ]] && continue
calc_add_language ${l}
if [[ "${l}" == 'en' ]] ; then
calc_add_language "${l}"
else
compare_nls "$i"
calc_add_language "${l}${EN_CMP}"
fi
(( TRANS++ ))
done
Expand Down Expand Up @@ -80,7 +170,7 @@ function calc_src_languages () {
esac
l=$(lang_of_nls "${i}")
[[ "${l}" == "" ]] && continue
calc_add_language ${l}
calc_add_language "${l}?"
(( TRANS++ ))
done
return 0
Expand All @@ -90,6 +180,7 @@ function calc_languages () {
APPLANGS=''
local prog
unset UC
calc_dir_languages ${1}/nls && prog=y
calc_dir_languages ${1}/help && prog=y
calc_src_languages ${1}/source && prog=y
Expand All @@ -98,7 +189,10 @@ function calc_languages () {
(( APPS++ ))
APPLANGS="${APPLANGS:1:$(( ${#APPLANGS} - 2))}"
APPLANGS="${APPLANGS//;/, }"
echo "${1}: ${APPLANGS}"
/bin/echo -n "${1}: ${APPLANGS}"
[[ ${UC} ]] && /bin/echo -n " (compare manually)"
echo
sleep 1
fi
return 0
Expand All @@ -120,11 +214,16 @@ function each_app () {
function main () {
local opt i
local once=yes
while [[ "${1}" != "" ]] ; do
while [[ "${1}" != "" ]] || [[ $once ]]; do
unset once
opt="${1}"
shift
if [[ "${opt}" == "-t" ]] ; then
if [[ "${opt}" == "-h" ]] ; then
script_help
return 0
elif [[ "${opt}" == "-s" ]] || [[ "${opt}" == "" ]]; then
each_app calc_languages
echo
echo "${APPS} total programs, ${LANGS} total languages, ${TRANS} total translations"
Expand All @@ -138,8 +237,4 @@ function main () {
}
if [[ ${#*} -eq 0 ]] ; then
script_help
else
main ${@}
fi
main ${@}
2 changes: 1 addition & 1 deletion slicer/nls/SLICER.EN
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; English Langauge Resource and Translation File

; note %_ is a space, %% is percent, %r is CRLF
; note %_ is a space, %% is percent, %r is CRLF,
; %0-F (1 char hex) are params, % alone is next param.
; Items that start VERB_ are Verbose mode versions.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 599c413

Please sign in to comment.