Found issue with references.

master
Lio Novelli 2020-04-27 23:18:16 +02:00
parent b26e703002
commit 70a07d6ae3
2 changed files with 2456 additions and 8 deletions

2445
test/went.json 100644

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@ pons_request() {
PONS_QUERY="$PONS_QUERY&ref=true" PONS_QUERY="$PONS_QUERY&ref=true"
fi fi
#echo "$PONS_QUERY" #echo "$PONS_QUERY"
PONS_JSON=$( curl -s --header "X-Secret: $PONS_SECRET" $PONS_URI$PONS_QUERY ) PONS_JSON=$( curl -s --header "X-Secret: $PONS_SECRET" $PONS_URI$PONS_QUERY | tr '\r\n' ' ' )
# check if type of hit is translation # check if type of hit is translation
pons_hits pons_hits
} }
@ -67,6 +67,7 @@ pons_filter() {
pons_tags() { pons_tags() {
source_t="$1" source_t="$1"
source_t=$( recode html..latin1 <<< $source_t ) source_t=$( recode html..latin1 <<< $source_t )
#source_t=$( recode html..latin9 <<< $source_t )
old_color="$2" old_color="$2"
spn_color="$3" spn_color="$3"
if [ -z $PONS_NOCOLOR ] ; then if [ -z $PONS_NOCOLOR ] ; then
@ -100,8 +101,8 @@ pons_parse() {
COLS=$(( $(tput cols) / 2 - 4 )) COLS=$(( $(tput cols) / 2 - 4 ))
PONS_COUNT=0 PONS_COUNT=0
for lang_key in $(jq -r '.| keys | .[]' <<< $PONS_JSON); do for lang_key in $(jq -r '.| keys | .[]' <<< $PONS_JSON); do
cur_lang=$(echo $PONS_JSON | jq ".[$lang_key] | .language_p" | sed -e 's/^"//' -e 's/"$//') cur_lang=$(echo "$PONS_JSON" | jq ".[$lang_key] | .language_p" | sed -e 's/^"//' -e 's/"$//')
sub_lang=$(echo $PONS_JSON | jq ".[$lang_key]"); sub_lang=$(echo "$PONS_JSON" | jq ".[$lang_key]");
if [ ! -z $PONS_LIMIT ] && [ "$PONS_COUNT" -gt "$PONS_LIMIT" ] ; then if [ ! -z $PONS_LIMIT ] && [ "$PONS_COUNT" -gt "$PONS_LIMIT" ] ; then
break break
fi fi
@ -191,7 +192,7 @@ pons_help () {
echo -e "\t-d [dict] :: Dictonary; Select language pair to translate in (ensl, desl, husl ...). For full list call with [-o] flag." echo -e "\t-d [dict] :: Dictonary; Select language pair to translate in (ensl, desl, husl ...). For full list call with [-o] flag."
echo -e "\t-f :: Fuzzy matching; Enable fuzzy matching results." echo -e "\t-f :: Fuzzy matching; Enable fuzzy matching results."
echo -e "\t-e :: Enable REference ; Not quite sure what this does yet." echo -e "\t-e :: Enable REference ; Not quite sure what this does yet."
echo -e "\t-n [num] :: Number; Limits the number of results." echo -e "\t-n [num] :: Number; Limits the number of results."
echo -e "\t-r :: Raw; Return raw result from pons." echo -e "\t-r :: Raw; Return raw result from pons."
# echo -e "\t-t [type] :: Type; Return results in this type, txt by default (json, csv)." # long term plan # echo -e "\t-t [type] :: Type; Return results in this type, txt by default (json, csv)." # long term plan
echo -e "\t-c :: Count; Count number of results." echo -e "\t-c :: Count; Count number of results."
@ -229,7 +230,7 @@ do
esac esac
done done
shift $((OPTIND -1)) shift $((OPTIND -1))
PONS_WORD=$1 PONS_WORD=$(php -r "echo rawurlencode('$1');")
if [ "$PONS_HELP" == "1" ] ; then if [ "$PONS_HELP" == "1" ] ; then
pons_help pons_help
@ -239,13 +240,15 @@ elif [ "$PONS_RAW" == "1" ] ; then
pons_config pons_config
pons_request pons_request
pons_filter pons_filter
PONS_JSON=$(echo $PONS_JSON | jq "$PONS_FILTER") PONS_JSON=$(echo "$PONS_JSON" | jq "$PONS_FILTER")
echo -e $PONS_JSON | jq . PONS_JSON=$(echo -e $PONS_JSON) #| jq '.'
echo $PONS_JSON | jq .
else else
pons_config pons_config
pons_request pons_request
pons_filter pons_filter
PONS_JSON=$(echo $PONS_JSON | jq "$PONS_FILTER") PONS_JSON=$( echo "$PONS_JSON" | jq "$PONS_FILTER" )
#PONS_JSON=$(jq $PONS_FILTER <<< $PONS_JSON)
if [ "$PONS_HITS" -gt 0 ] ; then if [ "$PONS_HITS" -gt 0 ] ; then
pons_parse_translate pons_parse_translate
else else