* Program:     _LOCALE_GENMENU.PRG
* Description: Loader to GenMenu.prg to adjust PROMPT and MESSAGE clauses for Localization.
* Created:     02/16/2004
* Developer:   Gregory L Reichert
* Copyright:   Copyright (c) 2004 GLR software
*------------------------------------------------------------

*--------------------------------------------
*  Setup instructions.
* 1. From the main menu, Open the Options dialogs.
* 2. Click the "File Locations" tab.
* 3. Locate the "Menu Builder" item in the list.
* 4. Doble-Click the "Menu Builder" item.
* 5. Change the file reference to point to this file.
* 6. Click the "Save as Default" button.
* 7. Click the "Ok" button.
*--------------------------------------------


PARAMETER m.projdbf, m.recno

LOCAL cResult, cPath, cc
cPath = SET("Path")
cc = HOME()+";&cPath"
SET PATH TO &cc
cResult = GenMenu( (m.projdbf), (m.recno) )
SET PATH TO &cPath

LOCAL MenuName, cMenu
LOCAL lcLocaleObjName
lcLocaleObjName = [goLocale]

*--------------------------------------------
*  Get menu name
*--------------------------------------------

USE IN (SELECT("qMenu"))
USE (m.projdbf) AGAIN IN 0 NOUPDATE ALIAS qMenu
SELECT qMenu
GOTO (m.recno)
m.MenuName = qMenu.NAME
USE IN qMenu

*--------------------------------------------
*  If there is a "*:Locale=Yes" in the Procedure section of 
* the "View->General Options", setup for translations. 
*--------------------------------------------
SELECT 0
lcMenuFile = LEFT(m.projdbf, RAT('\', m.projdbf)) + m.MenuName
USE (m.lcMenuFile) AGAIN NOUPDATE ALIAS qMenu
GOTO TOP
m.Proc = ALLTRIM(qMenu.procedure)
USE 
IF ATC("*:Locale=Yes",m.Proc)>0

	lcMenuFile = STRTRAN(LOWER(lcMenuFile),".mnx",".mpr")

	CREATE CURSOR qMenu (LINE c(250))
	APPEND FROM (lcMenuFile) TYPE SDF

	LOCAL cLine, i, cMenu
	cMenu = ""
	SCAN ALL
		cLine = ALLTRIM(qMenu.LINE)

		*%% Gregory L Reichert 02/16/2004 LOCALE_GENMENU.PRG : 800 : BUGBUG : Making direct reference to oLocale.  It may be on Form or _SCREEN at runtime.
		DO CASE
			CASE ATCC([DEFINE PAD ],cLine)>0 AND ATCC([PROMPT "],cLine)>0
				i = ATCC([PROMPT "],cLine)+7
				cLine = STUFFC(cLine,i,1, lcLocaleObjName + [.getString("])
				i = RATC([" COLOR ],cLine,1)
				cLine = STUFFC(cLine,i,1,[")])
			CASE ATCC([DEFINE BAR ],cLine)>0 AND ATCC([PROMPT "],cLine)>0
				i = ATCC([PROMPT "],cLine)+7
				cLine = STUFFC(cLine,i,1,lcLocaleObjName + [.getString("])
				i = RATC(["],cLine,1)
				cLine = STUFFC(cLine,i,1,[")])
			CASE ATCC([MESSAGE "],cLine)>0
				i = ATCC([MESSAGE "],cLine)+8
				cLine = STUFFC(cLine,i,1,lcLocaleObjName + [.getString("])
				i = ratc(["],cLine,1)
				cLine = STUFFC(cLine,i,1,[")])
			CASE ATCC([TITLE "],cLine)>0
				i = ATCC([TITLE "],cLine)+8
				cLine = STUFFC(cLine,i,1,lcLocaleObjName + [.getString("])
				i = ratc(["],cLine,1)
				cLine = STUFFC(cLine,i,1,[")])
			CASE ATCC([FOOTER "],cLine)>0
				i = ATCC([FOOTER "],cLine)+8
				cLine = STUFFC(cLine,i,1,lcLocaleObjName + [.getString("])
				i = ratc(["],cLine,1)
				cLine = STUFFC(cLine,i,1,[")])
		ENDCASE
		
		cLine = STRTRAN(cLine,"rat(","rat_c(")
		cLine = STRTRAN(cLine,"ratc(","ratcc(")
		cLine = STRTRAN(cLine,"at(","at_c(")
		cLine = STRTRAN(cLine,"atc(","atcc(")
		
		cMenu = cMenu + cLine + CHR(13)+CHR(10)
	ENDSCAN
	STRTOFILE(cMenu, lcMenuFile, .F.)
	USE IN qMenu
ENDIF

RETURN m.cResult


