Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Here is a way to translate menus on the fly
Message
De
10/02/2005 01:02:44
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de menu & Menus
Titre:
Here is a way to translate menus on the fly
Divers
Thread ID:
00985444
Message ID:
00985444
Vues:
63
This works well. For ease of reading, you can make menu prompts to be something like [Save As] (with the brackets).
PROCEDURE LocalizeMenu
LPARAMETERS tcMprFile,tcLanguage
	LOCAL lcMPR
	lcMPR = FILETOSTR(FORCEEXT(tcMprFile,'MPR'))
	IF EMPTY(lcMPR)
		RETURN
	ENDIF
        * Localize.dbf holds translations.  It has an index field (Tag), and a memo field for each language.
	SELECT Localize
	SCAN FOR UPPER(LEFT(Tag,5)) = 'MENU_'
		lcFrom = UPPER(ALLTRIM(SUBSTR(Tag,6)))
		lcTo   = EVALUATE(ALLTRIM(tcLanguage))
		lnStartPos = AT(lcFrom,UPPER(lcMPR))
		IF lnStartPos > 0
			lcMPR = STUFF(lcMPR,lnStartPos,LEN(lcFrom),lcTo)
		ENDIF
	ENDSCAN
	lcNewMenu = FORCEEXT(FORCEPATH(SYS(2015),SYS(2023)),'MPR')
	STRTOFILE(lcMPR,lcNewMenu)
	COMPILE (lcNewMenu)
	lcCompiledMenu = FORCEEXT(lcNewMenu,'MPX')
	DO (lcCompiledMenu)
Répondre
Fil
Voir

Click here to load this message in the networking platform