| 1 | /*:VRX NLVSetup
|
|---|
| 2 | */
|
|---|
| 3 | NLVSetup: PROCEDURE EXPOSE settings. options.
|
|---|
| 4 | /* This subroutine is (c) by Alex Taylor, portions (c) Herwig Bauernfeind
|
|---|
| 5 | * Sets all UI text from the message file. Any string that can't be loaded
|
|---|
| 6 | * will default to the built-in English.
|
|---|
| 7 | */
|
|---|
| 8 |
|
|---|
| 9 | IF options.!debug == 1 THEN SAY time()' NLVSetup() started'
|
|---|
| 10 | IF options.!debug == 1 THEN SAY ' NLVSetup() is (c) Alex Taylor, portions (c) Herwig Bauernfeind'
|
|---|
| 11 |
|
|---|
| 12 | execPath = VRGet("Application", "Program")
|
|---|
| 13 | if execPath = "" then parse source . . execPath
|
|---|
| 14 | execDir = VRParseFileName( execPath, "DP")
|
|---|
| 15 | say ' NLV execDir = "'execDir'"'
|
|---|
| 16 |
|
|---|
| 17 | filestem = VRParseFileName( execPath, "N")'_'
|
|---|
| 18 | if translate(filestem) = "EVFSGUI_" then filestem = "evfsi_"
|
|---|
| 19 | say ' NLV filestem = "'filestem'"'
|
|---|
| 20 |
|
|---|
| 21 | /* First, figure out what language/message file to use.
|
|---|
| 22 | */
|
|---|
| 23 | Syslang = TRANSLATE( VALUE('LANG',,'OS2ENVIRONMENT'))
|
|---|
| 24 | SELECT
|
|---|
| 25 | WHEN Syslang == 'ZH_TW' THEN nlv = 'tw'
|
|---|
| 26 | WHEN Syslang == 'ZH_CN' THEN nlv = 'cx'
|
|---|
| 27 | OTHERWISE PARSE VAR Syslang nlv '_' .
|
|---|
| 28 | END
|
|---|
| 29 |
|
|---|
| 30 | /* Find the language file */
|
|---|
| 31 | select
|
|---|
| 32 | when STREAM( execDir'\'filestem||nlv'.msg', 'C', 'QUERY EXISTS') \= '' then do
|
|---|
| 33 | say " Found NLV file directly!"
|
|---|
| 34 | settings.!messages = strip(execdir'\'filestem||nlv'.msg','L','\')
|
|---|
| 35 | settings.!helpfile = strip(execdir'\'filestem||nlv'.hlp','L','\')
|
|---|
| 36 | end
|
|---|
| 37 | when SysSearchPath('DPATH', filestem||nlv'.msg') \= '' THEN DO
|
|---|
| 38 | execDir = VRParseFileName(SysSearchPath('DPATH', filestem||nlv'.msg'),"DP")
|
|---|
| 39 | say " Found NLV file via DPATH"
|
|---|
| 40 | settings.!messages = strip(execdir'\'filestem||nlv'.msg','L','\')
|
|---|
| 41 | settings.!helpfile = strip(execdir'\'filestem||nlv'.hlp','L','\')
|
|---|
| 42 | end
|
|---|
| 43 | otherwise do
|
|---|
| 44 | /* Added by Herwig Bauernfeind */
|
|---|
| 45 | say " Searching subdirectories"
|
|---|
| 46 | ok = SysFileTree(execDir'\'filestem||nlv'.msg',nlvmsg.,'FOS')
|
|---|
| 47 | if nlvmsg.0 = 1 then do
|
|---|
| 48 | say " Found NLV file in subdirectory"
|
|---|
| 49 | settings.!messages = VRParseFilename(nlvmsg.1,"DPN")'.msg'
|
|---|
| 50 | settings.!helpfile = VRParseFilename(nlvmsg.1,"DPN")'.hlp'
|
|---|
| 51 | say " Adding NLV file path to DPATH"
|
|---|
| 52 | OldDPATH = value("DPATH",,"OS2ENVIRONMENT")
|
|---|
| 53 | ok = value("DPATH",VRParseFilename(nlvmsg.1,"DP")';'OldDPATH,"OS2ENVIRONMENT")
|
|---|
| 54 | say " DPATH="value("DPATH",,"OS2ENVIRONMENT")
|
|---|
| 55 | /* End addition by Herwig Bauernfeind */
|
|---|
| 56 | end
|
|---|
| 57 | else do
|
|---|
| 58 | say " Fallback to English"
|
|---|
| 59 | if STREAM( execDir'\'filestem||'en.msg', 'C', 'QUERY EXISTS') = '' then do
|
|---|
| 60 | say " Found English via DPATH"
|
|---|
| 61 | execDir = VRParseFileName(SysSearchPath('DPATH', filestem||'en.msg'),"DP")
|
|---|
| 62 | end
|
|---|
| 63 | settings.!messages = strip(execDir'\'filestem||'en.msg','L','\')
|
|---|
| 64 | settings.!helpfile = strip(execDir'\'filestem||'en.hlp','L','\')
|
|---|
| 65 | end
|
|---|
| 66 | end
|
|---|
| 67 | end
|
|---|
| 68 |
|
|---|
| 69 | /* In case the message file exists but not the help file */
|
|---|
| 70 | if STREAM( settings.!helpfile , 'C', 'QUERY EXISTS') = "" then do
|
|---|
| 71 | settings.!helpfile = strip(execDir'\'filestem||'en.hlp','L','\')
|
|---|
| 72 | end
|
|---|
| 73 |
|
|---|
| 74 | IF options.!debug == 1 THEN SAY ' NLVMessageFile = "'settings.!messages'"'
|
|---|
| 75 | IF options.!debug == 1 THEN SAY ' NLVHelpFile = "'settings.!helpfile'"'
|
|---|
| 76 |
|
|---|
| 77 | IF options.!debug == 1 THEN SAY time()' NLVSetup() done'
|
|---|
| 78 | RETURN
|
|---|
| 79 |
|
|---|
| 80 | /*:VRX NLVGetMessage
|
|---|
| 81 | */
|
|---|
| 82 | NLVGetMessage: PROCEDURE EXPOSE settings. options. fs.
|
|---|
| 83 |
|
|---|
| 84 | msgfile = settings.!messages
|
|---|
| 85 | msgnum = ARG( 1 )
|
|---|
| 86 |
|
|---|
| 87 | IF msgnum == '' THEN RETURN ''
|
|---|
| 88 |
|
|---|
| 89 | SELECT
|
|---|
| 90 | WHEN ARG() == 2 THEN
|
|---|
| 91 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2) )
|
|---|
| 92 | WHEN ARG() == 3 THEN
|
|---|
| 93 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3) )
|
|---|
| 94 | WHEN ARG() == 4 THEN
|
|---|
| 95 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4) )
|
|---|
| 96 | WHEN ARG() == 5 THEN
|
|---|
| 97 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5) )
|
|---|
| 98 | WHEN ARG() == 6 THEN
|
|---|
| 99 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5), ARG(6) )
|
|---|
| 100 | WHEN ARG() == 7 THEN
|
|---|
| 101 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7) )
|
|---|
| 102 | WHEN ARG() == 8 THEN
|
|---|
| 103 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8) )
|
|---|
| 104 | WHEN ARG() == 9 THEN
|
|---|
| 105 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9) )
|
|---|
| 106 | WHEN ARG() == 10 THEN
|
|---|
| 107 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9), ARG(10) )
|
|---|
| 108 | OTHERWISE
|
|---|
| 109 | msgtxt = SysGetMessage( msgnum, msgfile )
|
|---|
| 110 | END
|
|---|
| 111 |
|
|---|
| 112 | PARSE VAR msgtxt message '0D'x .
|
|---|
| 113 |
|
|---|
| 114 | IF translate(SUBSTR( message, 1, 4 )) == 'SYS0' THEN message = ''
|
|---|
| 115 |
|
|---|
| 116 | RETURN message
|
|---|
| 117 |
|
|---|
| 118 | /*:VRX NLVSetText
|
|---|
| 119 | */
|
|---|
| 120 | /*
|
|---|
| 121 | * Sets the specified property of the specified control to the specified
|
|---|
| 122 | * message text.
|
|---|
| 123 | */
|
|---|
| 124 | NLVSetText: PROCEDURE EXPOSE settings. options. fs.
|
|---|
| 125 | PARSE ARG control, property, message, substitution
|
|---|
| 126 |
|
|---|
| 127 | success = 1
|
|---|
| 128 | IF substitution == '' THEN
|
|---|
| 129 | text = NLVGetMessage( message )
|
|---|
| 130 | ELSE
|
|---|
| 131 | text = NLVGetMessage( message, substitution )
|
|---|
| 132 |
|
|---|
| 133 | IF text == '' THEN success = 0
|
|---|
| 134 | ELSE CALL VRSet control, property, text
|
|---|
| 135 |
|
|---|
| 136 | RETURN success
|
|---|