Page 1 of 1

Translate words in dbf fields with other words

Posted: Fri Mar 20, 2020 2:43 pm
by Marc Venken
Hello,

I want to translate words from products data into my language.

I was thinking of a Xbrowse with 2 columns

Flemisch - English

Zwart - Black
Broek - Trouwsers
Broek - Trouwser
etc...

The product database will then be checked for the field "Description" and find all englisch words to convert.../ changed in the same dbf.
There are so many functions ))


I have seen functions like : dbftoarr, At, Tokens, ....

Can i have a start idea to proceed ?

Re: Translate words in dbf fields with other words

Posted: Fri Mar 20, 2020 5:09 pm
by nageswaragunupudi
You need to translate whole words, searching case-insensitive.

Use this function

Code: Select all

FW_AT( acSub, cString, nStart, nEnd, lWholeWord, lSkipQuotes, cFound, cReplace, lAll )
 
in this manner:

Code: Select all

aTranslate := ;
   {  { "Zwart", "Black" } ;
   ,  { "Broek", "Trouwsers" } ;
   ,  { "Broek", "Trouwser" } ;
   }
   
   do while !eof()
   
      cDesc := FIELD->DESCRIPTION
      for n := 1 to Len( aTranslate )
         FW_AT( aTranslate[ n, 2 ], @cDesc, nil, nil, .t., .f., nil, aTranslate[ n, 1 ], .t. )
      next
      FIELD->DESCRIPTON := cDesc
      
      SKIP
   enddo
 

Re: Translate words in dbf fields with other words

Posted: Fri Mar 20, 2020 8:11 pm
by Marc Venken
Very Nice and working. Thanks !