Translate words in dbf fields with other words

Translate words in dbf fields with other words

Postby Marc Venken » Fri Mar 20, 2020 2:43 pm

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 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1429
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Translate words in dbf fields with other words

Postby nageswaragunupudi » Fri Mar 20, 2020 5:09 pm

You need to translate whole words, searching case-insensitive.

Use this function
Code: Select all  Expand view

FW_AT( acSub, cString, nStart, nEnd, lWholeWord, lSkipQuotes, cFound, cReplace, lAll )
 


in this manner:

Code: Select all  Expand view

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
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Translate words in dbf fields with other words

Postby Marc Venken » Fri Mar 20, 2020 8:11 pm

Very Nice and working. Thanks !
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1429
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 96 guests