-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathidlitsrvlangcat__define.pro
278 lines (238 loc) · 6.38 KB
/
idlitsrvlangcat__define.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
; $Id: //depot/idl/releases/IDL_80/idldir/lib/itools/framework/idlitsrvlangcat__define.pro#1 $
;
; Copyright (c) 2003-2010, ITT Visual Information Solutions. All
; rights reserved. Unauthorized reproduction is prohibited.
;+
; CLASS_NAME:
; IDLitsrvLangCat
;
; PURPOSE:
; This file implements the IDL Tool services needed for using
; the language catalogs
;
; CATEGORY:
; Internationalization
;
; SUPERCLASSES:
; IDLitOperation
;
; SUBCLASSES:
; This class has no subclasses.
;
; CREATION:
; Created by the Tool system routines.
;
; METHODS:
; IDLitsrvLangCat::Query
; IDLitsrvLangCat::SetLanguage
; IDLitsrvLangCat::GetAvailableLanguages
;
; MODIFICATION HISTORY:
; Created by: AGEH, December 2003
;-
;;----------------------------------------------------------------------------
;; IDLitsrvLangCat::Init
;;
;; Purpose:
;; Initialization routine
;;
;; Parameters:
;; NONE
;;
;; Keywords:
;; SIMPLE - If set only create this object, do not call init on
;; superclasses. This is so that the member data can be
;; retrieved via get property without creating additional
;; resources.
;;
FUNCTION IDLitsrvLangCat::Init, SIMPLE=simple, _extra=_extra
compile_opt hidden,idl2
;; set initial values
self._application = ptr_new(['itools*'])
self._appDirName = 'itools'
self._defaultLang = 'English'
self._verbose = 0
IF KEYWORD_SET(simple) THEN return,1
return, self->IDLitOperation::Init(NAME='Language Catalog', _extra=_extra)
END
;;----------------------------------------------------------------------------
;; IDLitsrvLangCat::Query
;;
;; Purpose:
;; Returns the string, or array of strings, that correspond with the
;; supplied key value(s).
;;
;; Parameters:
;; KEY (required) - A string, or array of strings
;;
;; Keywords:
;; NONE
;;
;; Return value:
;; The string, or array of strings, one element for each element of KEY
;;
FUNCTION IDLitsrvLangCat::Query, key
compile_opt hidden, idl2
IF ~obj_valid(self._oLangCat) THEN $
return, 'No Valid LangCat Object'
str = self._oLangCat->Query(key, DEFAULT_STRING='Key Not Found ['+key+']')
return, str
END
;;----------------------------------------------------------------------------
;; IDLitsrvLangCat::SetLanguage
;;
;; Purpose:
;; Sets the language for the catalog
;;
;; Parameters:
;; LANGUAGE - a string containing the name of the LANGUAGE to load
;; from the catalog.
;;
;; Keywords:
;; NONE
;;
PRO IDLitsrvLangCat::SetLanguage, language
compile_opt hidden, idl2
IF n_elements(language) EQ 0 THEN return
IF ~obj_valid(self._oLangCat) THEN BEGIN
self._oLangCat = obj_new('IDLffLangCat',language[0], $
APP_NAME=*self._application, $
RSI_APP_PATH=self._appDirName, $
DEFAULT_LANGUAGE=self._defaultLang, $
VERBOSE=self._verbose)
ENDIF ELSE BEGIN
self._oLangCat->SetProperty,language=language[0]
ENDELSE
END
;;----------------------------------------------------------------------------
;; IDLitsrvLangCat::GetAvailableLanguages
;;
;; Purpose:
;; Returns string array of available languages
;;
;; Parameters:
;; NONE
;;
;; Keywords:
;; NONE
;;
;; Return value:
;; A string array containing the available languages
;;
FUNCTION IDLitsrvLangCat::GetAvailableLanguages
compile_opt hidden,idl2
IF obj_valid(self._oLangCat) THEN $
self._oLangCat->GetProperty,Available_languages=availLangs $
ELSE $
availLangs = ''
return, availLangs
END
;;----------------------------------------------------------------------------
;; IDLitsrvLangCat::GetLanguage
;;
;; Purpose:
;; Returns string of current language
;;
;; Parameters:
;; NONE
;;
;; Keywords:
;; NONE
;;
;; Return value:
;; A string containing the current languages
;;
FUNCTION IDLitsrvLangCat::GetLanguage
compile_opt hidden,idl2
IF obj_valid(self._oLangCat) THEN $
self._oLangCat->GetProperty,LANGUAGE=language $
ELSE $
language = ''
return, language
END
;;----------------------------------------------------------------------------
;; IDLitsrvLangCat::_GetDefaultLanguage
;;
;; Purpose:
;; Returns string array of default language
;;
;; Parameters:
;; NONE
;;
;; Keywords:
;; NONE
;;
FUNCTION IDLitsrvLangCat::_GetDefaultLanguage
compile_opt hidden,idl2
return, self._defaultLang
END
;;----------------------------------------------------------------------------
;; IDLitsrvLangCat::GetProperty
;;
;; Purpose:
;; Retrieves a property or some properties
;;
;; Parameters:
;; NONE
;;
;; Keywords:
;; NONE
;;
PRO IDLitsrvLangCat::GetProperty, APP_NAME=appName, $
RSI_APP_PATH=rsiAppPath, $
VERBOSE=verbose, $
_REF_EXTRA=_extra
compile_opt hidden,idl2
if (ARG_PRESENT(appName)) then $
appName = ptr_valid(self._application) ? *self._application : ''
if (ARG_PRESENT(rsiAppPath)) then $
rsiAppPath = self._appDirName
if (ARG_PRESENT(verbose)) then $
verbose = self._verbose
IF (n_elements(_extra) GT 0) then begin
if obj_valid(self._oLangCat) THEN $
self._oLangCat->GetProperty, _EXTRA=_extra
self->IDLitOperation::GetProperty, _EXTRA=_extra
endif
END
;;----------------------------------------------------------------------------
;; IDLitsrvLangCat::Cleanup
;;
;; Purpose:
;; Cleanup routine
;;
;; Parameters:
;; NONE
;;
;; Keywords:
;; NONE
;;
PRO IDLitsrvLangCat::Cleanup
compile_opt hidden,idl2
ptr_free,self._application
obj_destroy,self._oLangCat
self->IDLitOperation::Cleanup
END
;;----------------------------------------------------------------------------
;; IDLitsrvLangCat__Define
;;
;; Purpose:
;; Definition procedure for the IDLitsrvLangCat object
;;
;; Parameters:
;; NONE
;;
;; Keywords:
;; NONE
;;
PRO IDLitsrvLangCat__define
compile_opt idl2, hidden
struct = {IDLitsrvLangCat, $
inherits IDLitOperation, $
_oLangCat : obj_new(), $
_appDirName : '', $
_application : ptr_new(), $
_defaultLang : '', $
_verbose : 0 $
}
END