Translate words in dbf fields with other words

Post Reply
User avatar
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Translate words in dbf fields with other words

Post 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 ?
Marc Venken
Using: FWH 20.08 with Harbour
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Translate words in dbf fields with other words

Post 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
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Re: Translate words in dbf fields with other words

Post by Marc Venken »

Very Nice and working. Thanks !
Marc Venken
Using: FWH 20.08 with Harbour
Post Reply