source: internationalization/trunk/p/RRCI18N.m@ 660

Last change on this file since 660 was 604, checked in by George Lilly, 15 years ago

Internationalization

File size: 4.5 KB
RevLine 
[604]1RRCI18N ; Internationalization Converter
2 ;RRCI18N V0.0001;;MTZ/RCR/27MAY2004
3 ;Donated by Chris Richardson
4 ;Initial database design by Marcus Werner
5 ;Copyright 2008 WorldVistA. Licensed under the terms of the GNU
6 ;General Public License See attached copy of the License.
7 ;
8 ;This program is free software; you can redistribute it and/or modify
9 ;it under the terms of the GNU General Public License as published by
10 ;the Free Software Foundation; either version 2 of the License, or
11 ;(at your option) any later version.
12 ;
13 ;This program is distributed in the hope that it will be useful,
14 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;GNU General Public License for more details.
17 ;
18 ;You should have received a copy of the GNU General Public License along
19 ;with this program; if not, write to the Free Software Foundation, Inc.,
20 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21V ; Note: Snapshot file .84 before this run so that
22 ; it might be restored completely, if needed.
23 N CODE,EX,I,J,K,LL,RRCODE,RRCFILE,RRCIEN,RRCNODE,MSK
24 S (CODE,RRCODE(1,0))="$$EZBLD^DIALOG("
25 S MSK=$$NAMEMSK(),RRCIEN=2150000000
26 Q:MSK=""
27 ;
28 S EX=0
29 S J=RRCIEN-1
30 F S J=$O(^DI(.84,J)) Q:('J)!(J>2159999999) D
31 . S I=$G(^DI(.84,J,0)),S42=$P(I,"^",3)
32 . K ^DI(.84,J),^DI(.84,"B",J)
33 . ; Dump all generated xrefs
34 . K:$L(S42) ^DI(.84,"D",S42,J)
35 .QUIT
36 D CLEAN
37 S TRGDIR="/tmp/I18N/r/"
38 ; Clear the decks
39 ZSY "mkdir -p "_TRGDIR
40 ZSY "rm -f "_TRGDIR_"[A-G]*.m"
41 ZSY "rm -f "_TRGDIR_"[G-K]*.m"
42 ZSY "rm -f "_TRGDIR_"[K-M]*.m"
43 ZSY "rm -f "_TRGDIR_"[M-P]*.m"
44 ZSY "rm -f "_TRGDIR_"[P-W]*.m"
45 ZSY "rm -f "_TRGDIR_"[W-Z]*.m"
46 ZSY "rm -f "_TRGDIR_"*.m"
47 ; D REINDX
48 F D Q:EX
49 . S RRCFILE=$ZSEARCH(MSK)
50 . I RRCFILE="" S EX=1 Q
51 . ;
52 . N CC,LC,X
53 . S (CC,LC)=0
54 . S RTN=$P(RRCFILE,"/",$L(RRCFILE,"/"))
55 . O RRCFILE:READ
56 . S RRCNUFL=TRGDIR_RTN
57 . S RTN=$P(RTN,".")
58 . O RRCNUFL:NEW
59 . U RRCFILE
60 . F LL=1:1 R X Q:'$L(X) D
61 . . N NL
62 . . S NL=""
63 . . S CC=CC+$L(X),LC=LC+1
64 . . S X=$$PULLSTR(X)
65 . . U RRCNUFL
66 . . W X,!
67 . . U RRCFILE
68 . .QUIT
69 . C RRCNUFL
70 . C RRCFILE
71 . U 0
72 . W RTN_":"_LC_":"_CC_" "
73 . W:$X>65 !
74 .QUIT
75 QUIT
76 ; ============
77NAMEMSK() ; Request the File Search Seed, ie. r/*.m
78 N M
79 R !,"Enter the file mask to include: ",M,!
80 QUIT M
81 ; ============
82 ; Note:
83 ; I L?3.A <== Picked up a lot of the DIC(0)=Setups
84 ;
85PULLSTR(LN) ; Look for strings
86 N J,K,L,LX,L42,RL,NL
87 S NL=""
88 F J=2:2:$L(LN,"""") D
89 . S NL=NL_$P(LN,"""",J-1)_""""
90 . S (L,LX)=$P(LN,"""",J)
91 . S L42=$E(L,1,42)
92 . D:$L(L42)
93 . . I '$D(^VWDI(250.84,"B",L42)) D Q ; Check the Exclusions
94 . . . I L'?1"["1U.(1" ",1.UNP).1"]",L?.E2.A1." "2.A.E D MOD Q
95 . . . ; I L?3.A D MOD Q
96 . . . I L?3.(1" "1AP) D MOD Q
97 . . . I L?2.(1.2AN1":"1.AP1";") D MOD Q
98 . . . I L?1U1.A.1(1" ",1":",1";").E D MOD Q
99 . . .QUIT
100 . . ;
101 . . ; Now if no condition found, add string into NL
102 . . S NL=NL_L_""""
103 . .QUIT
104 .QUIT
105 S K=$P(LN,"""",J+1)
106 S:K'="" NL=NL_K
107 S:NL="" NL=LN
108 QUIT NL
109 ; ============
110MOD ; Modify the Line of Code
111 ; D
112 ; . I $L(L)>60 S L=$E(L,1,60),^RRCSTR(L,RRCFILE,LL,J,"STR")=LX Q
113 ; . ;
114 ; . S ^RRCSTR(L,RRCFILE,LL,J)=""
115 ; .QUIT
116 ; Get or build a new IEN for this string and return in RL
117 S RL=$$RESOLVE(LX)
118 S:$E(NL,$L(NL))="""" NL=$E(NL,1,$L(NL)-1)
119 S NL=NL_CODE_RL_")"
120 QUIT
121 ; ============
122RESOLVE(ST) ; Resolve the String as being in DIALOG or add it.
123 N J,K,L,S42,S60
124 S S60=ST
125 S:$L(ST)>59 S60=$E(ST,1,60)
126 S S42=$E(S60,1,42)
127 S J=$O(^DI(.84,"D",S42,""))
128 D:J=""
129 . S (RRCIEN,J)=RRCIEN+1
130 . S ^DI(.84,J,0)=J_"^1^"_S42
131 . S ^DI(.84,J,2,0)="^.844^1^1"
132 . S ^DI(.84,J,2,1,0)=ST
133 . S ^DI(.84,"B",J,J)=""
134 . S ^DI(.84,"D",S42,J)=RTN
135 .QUIT
136 S D1=$O(^DI(.84,J,5,"B",RTN,""))
137 D:'D1
138 . S D1=$P($G(^DI(.84,J,5,0)),"^",3)+1
139 . S ^DI(.84,J,5,0)="^.841^"_D1_"^"_D1
140 .QUIT
141 S ^DI(.84,J,5,D1,0)=RTN_"^"_LL
142 S ^DI(.84,J,5,"B",RTN,D1)=""
143 QUIT J
144 ; ============
145CLEAN ; Check the "D" Cross Reference and Clear Inconsistancies
146 N I,J,K,L,M
147 S I=""
148 F S I=$O(^DI(.84,"D",I)) Q:I="" D
149 . S J=""
150 . F S J=$O(^DI(.84,"D",I,J)) Q:J="" D
151 . . S K=$P($G(^DI(.84,J,0)),"^",3)
152 . . I I'=K K ^DI(.84,"D",I,J)
153 . .QUIT
154 .QUIT
155 QUIT
156 ; ===========
157
158
Note: See TracBrowser for help on using the repository browser.