Google-Wikipedia-Mathematica...dictionary

You can share your experience with HMG. Share with some screenshots/project details so that others will also be benefited.

Moderator: Rathinagiri

Post Reply
User avatar
nguyenchiduc
Posts: 78
Joined: Sat Nov 13, 2010 7:27 am

Google-Wikipedia-Mathematica...dictionary

Post by nguyenchiduc »

I think this is a utility, rather than projects.

When reading a document: .chm, .txt, .html , .pdf ... sometimes we need to know what it is => WIKIPEDIA
Or translated from one language into another language => GOOGLE Dictionary

I've tested with HMG3, Windows XP, IE8. Runs good, though slightly slower than directly into IE.

Currently, only 10 languages options. Please help me complete the program

I think there may be many other websites like Google or Wikipedia is more convenient, please help me updated.

Image
Image

Code: Select all

#include "hmg.ch"

Function Main
     System.Clipboard := 'Welcome to hmgforum.com'	
	
     DEFINE WINDOW Win AT 0,0 WIDTH 800 HEIGHT 500 NOSIZE NOMAXIMIZE MAIN ON LOSTFOCUS close() 
          @ 0,0 LABEL label_show WIDTH 1 HEIGHT 1 value '' INVISIBLE
          @ 0,0 LABEL value1 WIDTH 1 HEIGHT 1 value '' INVISIBLE
	   
          @ 10,5 LABEL Label_from WIDTH 40 HEIGHT 20 value 'FROM'
          @ 5,45 COMBOBOX Combo_From WIDTH 120 ITEMS {'1-English','2-French','3-Spanish','4-Portuguese','5-Turkish','6-Czech','7-Polish','8-Russian','9-Romanian','10-Vietnamese'} VALUE 1
          @ 10,180 LABEL Label_to WIDTH 30 HEIGHT 20 value 'TO'
          @ 5,210 COMBOBOX Combo_to WIDTH 120 ITEMS { '1-English', '2-French','3-Spanish','4-Portuguese','5-Turkish','6-Czech','7-Polish','8-Russian','9-Romanian','10-Vietnamese'} VALUE 1
          @ 10,380 LABEL Label_system WIDTH 60 HEIGHT 20 value 'SYSYTEM'
          @ 5,450 COMBOBOX Combo_system WIDTH 120 ITEMS {'1-Dictionary', '2-Wikipedia','3-None'} VALUE 1
	   	  
          @ 30,5 ACTIVEX translate WIDTH 785  HEIGHT 430 PROGID "shell.explorer"
          DEFINE TIMER Timer_1 INTERVAL 500 ACTION dictionary()                 
     END WINDOW
     ACTIVATE WINDOW Win
Return

FUNCTION dictionary()
     LOCAL value2 := '' , address := '' 
     value2 := System.Clipboard 
     value2 := alltrim(value2)  
    
     IF win.value1.value <> value2
          win.value1.value := value2
		
          DO CASE
		CASE Win.Combo_system.Value == 1
			Win.Title := "GOOGLE DICTIONARY"
			address := 'http://translate.google.com/#'
			
			DO CASE 
			CASE Win.Combo_From.Value == 1
				address := address + 'en|'
			CASE Win.Combo_From.Value == 2
				address := address + 'fr|'
			CASE Win.Combo_From.Value == 3
				address := address + 'es|'
			CASE Win.Combo_From.Value == 4
				address := address + 'pt|'
			CASE Win.Combo_From.Value == 5
				address := address + 'tr|'
			CASE Win.Combo_From.Value == 6
				address := address + 'cs|'
			CASE Win.Combo_From.Value == 7
				address := address + 'pl|'
			CASE Win.Combo_From.Value == 8
				address := address + 'ru|'
			CASE Win.Combo_From.Value == 9
				address := address + 'ro|'
			CASE Win.Combo_From.Value == 10
				address := address + 'vi|'
			ENDCASE
		
			DO CASE 
			CASE Win.Combo_To.Value == 1
				address := address + 'en|' + value2
			CASE Win.Combo_To.Value == 2
				address := address + 'fr|' + value2
			CASE Win.Combo_To.Value == 3
				address := address + 'es|' + value2
			CASE Win.Combo_To.Value == 4
				address := address + 'pt|' + value2
			CASE Win.Combo_To.Value == 5
				address := address + 'tr|' + value2
			CASE Win.Combo_To.Value == 6
				address := address + 'cs|' + value2
			CASE Win.Combo_To.Value == 7
				address := address + 'pl|' + value2
			CASE Win.Combo_To.Value == 8
				address := address + 'ru|' + value2
			CASE Win.Combo_To.Value == 9
				address := address + 'ro|' + value2
			CASE Win.Combo_To.Value == 10
				address := address + 'vi|' + value2
			ENDCASE
		
			Win.translate.Object:Navigate(address)      
			Win.label_show.value := 'T'
		
		CASE Win.Combo_system.Value == 2
			Win.Title := "WIKIPEDIA - " + value2
			
			DO CASE 
			CASE Win.Combo_From.Value == 1
				address := 'http://en.wikipedia.org/wiki/' + value2
			CASE Win.Combo_From.Value == 2
				address := 'http://fr.wikipedia.org/wiki/' + value2
			CASE Win.Combo_From.Value == 3
				address := 'http://es.wikipedia.org/wiki/' + value2
			CASE Win.Combo_From.Value == 4
				address := 'http://pt.wikipedia.org/wiki/' + value2
			CASE Win.Combo_From.Value == 5
				address := 'http://tr.wikipedia.org/wiki/' + value2
			CASE Win.Combo_From.Value == 6
				address := 'http://cs.wikipedia.org/wiki/' + value2
			CASE Win.Combo_From.Value == 7
				address := 'http://pl.wikipedia.org/wiki/' + value2
			CASE Win.Combo_From.Value == 8
				address := 'http://ru.wikipedia.org/wiki/' + value2
			CASE Win.Combo_From.Value == 9
				address := 'http://ro.wikipedia.org/wiki/' + value2
			CASE Win.Combo_From.Value == 10
				address := 'http://vi.wikipedia.org/wiki/' + value2
			ENDCASE
			
			Win.translate.Object:Navigate(address)      
			Win.label_show.value := 'T'
			
          ENDCASE
     ELSE
          Win.label_show.value := 'F'
     ENDIF
	
     IF Win.label_show.value == 'T'
          Win.Restore	  
     ENDIF

RETURN

Function close()  	
        Win.Minimize
Return
Attachments
tudientructuyen.rar
(580.22 KiB) Downloaded 400 times
Last edited by nguyenchiduc on Wed Mar 23, 2011 2:40 am, edited 3 times in total.
User avatar
nguyenchiduc
Posts: 78
Joined: Sat Nov 13, 2010 7:27 am

Re: Google - Wikipedia dictionary

Post by nguyenchiduc »

I was just down the street to buy a pack of cigarettes and think of an idea.

If hmgforum integrated harbour (CA-Clipper) and HMG documents will be very handy reference when programming. Especially for beginners with HMG

This is similar to Microsoft's HELP

================================

I added a special utility for mathematical and Youtube.com

Image

Image
Attachments
dictionary.rar
(589.04 KiB) Downloaded 420 times
User avatar
nguyenchiduc
Posts: 78
Joined: Sat Nov 13, 2010 7:27 am

Re: Google-Wikipedia-Mathematica...dictionary

Post by nguyenchiduc »

I test for Arabic and Vietnamese language, shows the error.

From English to Arabic => It's OK but From Arabic to English => It's error
From English to Vietnamese => It's OK but From Vietnamese to English => It's error

Because they are Unicode fonts on the Internet, while HMG only ASCII.

I think the same for languages like Chinese, Korean, Japanese ...

============

Again I would say from my heart:

HMG wants to be popular internationally, it must support Unicode for the import/export Unicode characters, or have a technique to convert
dtoledo
Posts: 5
Joined: Thu Jul 22, 2010 2:07 am
Location: Santiago de Chile

Re: Google-Wikipedia-Mathematica...dictionary

Post by dtoledo »

Hi Nguyen:

It's very interesting what you're doing.
I have not tried it, but I think can be useful for you, that I found in the Harbour's changelog:
+ added two prg functions for translations from/to UTF-8:
HB_STRTOUTF8( <cStr> [, <cCPID> ] ) -> <cUTF8Str>
HB_UTF8TOSTR( <cUTF8Str> [, <cCPID> ] ) -> <cStr>
<cCPID> is Harbour codepage id, f.e.: "EN", "ES", "ESWIN",
"PLISO", "PLMAZ", "PL852", "PLWIN", ...
When not given then default HVM codepage (set by HB_SETCODEPAGE())
is used.
Regards from Chile,

Dago :P

EDITED:
I found this in the Massimo Belgrano's blog, and i hope will be useful for you
http://harbourlanguage.blogspot.com/sea ... l/codepage
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Google-Wikipedia-Mathematica...dictionary

Post by Rathinagiri »

Nice utilities.

Yes, unicode is really a required thing for HMG.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
nguyenchiduc
Posts: 78
Joined: Sat Nov 13, 2010 7:27 am

Re: Google-Wikipedia-Mathematica...dictionary

Post by nguyenchiduc »

dtoledo wrote:Hi Nguyen:

It's very interesting what you're doing.
I have not tried it, but I think can be useful for you, that I found in the Harbour's changelog:
Thank you!
Finally I discovered a trick to solve. This trick does not apply to other languages.
Hopefully there is someone in Vietnam, I will share these tips.
Post Reply