author | Claus Gittinger <cg@exept.de> |
Tue, 23 Apr 2019 16:30:55 +0200 | |
changeset 8674 | e29a561c0fbe |
parent 8667 | 6b5cdd36a62f |
child 8675 | 62c554057380 |
permissions | -rw-r--r-- |
8445 | 1 |
"{ Encoding: utf8 }" |
2 |
||
5 | 3 |
" |
4 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
8462 | 5 |
All Rights Reserved |
5 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
3263 | 14 |
"{ Package: 'stx:libview' }" |
15 |
||
6767 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
Dictionary subclass:#ResourcePack |
8470 | 19 |
instanceVariableNames:'packsClassName packsFileName fileReadFailed superPack projectPack |
8510 | 20 |
usedKeys cache superPacks' |
21 |
classVariableNames:'DebugModifications FailedToLoadPacks KeepStatisticsOnUsedKeys |
|
8667 | 22 |
Packs LastLanguageChosen DebugResources' |
8470 | 23 |
poolDictionaries:'' |
24 |
category:'Interface-Internationalization' |
|
0 | 25 |
! |
26 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
27 |
!ResourcePack class methodsFor:'documentation'! |
46 | 28 |
|
29 |
copyright |
|
30 |
" |
|
31 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
8462 | 32 |
All Rights Reserved |
5 | 33 |
|
46 | 34 |
This software is furnished under a license and may be used |
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
5 | 42 |
|
46 | 43 |
documentation |
44 |
" |
|
1942 | 45 |
This class supports easy customization of smalltalk code (i.e. internationalization |
46 |
and viewStyle adaption). |
|
145 | 47 |
ResourcePacks are class specific, meaning that every subclass of View |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
48 |
and ApplicationModel has an instance of ResourcePack (instVar called 'resources') |
1942 | 49 |
which is created when the first instance of the view/app is created, |
50 |
and cached in a class-instVar (so the file is only read once). |
|
54 | 51 |
|
50 | 52 |
The resourcePack consists of a mapping from strings to values, which are |
53 |
then used in labels, buttons, menus etc. |
|
54 |
The resourcePack initializes itself from a file found in 'resources/<className>.rs', |
|
55 |
where 'className' is built by the usual abbreviation mechanism (see abbrev-files). |
|
1942 | 56 |
|
50 | 57 |
Conditional mappings are possible, by including lines as: |
7649 | 58 |
#if <expression> |
59 |
#endif |
|
50 | 60 |
in the resourcefile. Example: |
61 |
file 'foo.rs': |
|
7649 | 62 |
#if Language == #de |
63 |
'abort' 'Abbruch' |
|
64 |
#endif |
|
65 |
#if Language == #fr |
|
66 |
'abort' 'canceller' |
|
67 |
#endif |
|
145 | 68 |
|
69 |
the corresponding resource-strings are accessed (from methods within the class) |
|
70 |
using: |
|
7649 | 71 |
resources string:'abort' |
145 | 72 |
|
54 | 73 |
returning the mapped string (i.e. 'Abbruch' if the global Language is set |
3422 | 74 |
to #de).. |
145 | 75 |
|
1942 | 76 |
If no corresponding entry is found in the resources, the key is returned; |
77 |
alternatively, use: |
|
7649 | 78 |
resources string:'foo' default:'bar' |
1942 | 79 |
which returns 'bar', if no resource definition for 'foo' is found. |
80 |
||
54 | 81 |
Translations can also include arguments, such as: |
7649 | 82 |
resources string:'really delete %1' with:fileName |
145 | 83 |
|
84 |
This scheme has the advantage, that you can write your programs using your |
|
85 |
native language strings. Later, when new languages are to be supported, |
|
86 |
simply create a resource file for the class and add translations for |
|
87 |
all those strings. (find the keys by looking at users of resource or senders |
|
1942 | 88 |
of 'string:*'). |
89 |
Notice, that the grammar of different languages may imply a reordering, |
|
8445 | 90 |
so the above string becomes the german 'wollen Sie %1 wirklich löschen'; |
1942 | 91 |
so using percent-placeholders is much better than simple concatenations of |
92 |
arguments to the question. |
|
145 | 93 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
94 |
More languages can be added later without any change in the code, or recompilation |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
95 |
or the like. Even by people without access to the source code (i.e. which only have the |
8428 | 96 |
application's binary). |
145 | 97 |
|
98 |
Also, unsupported languages' strings are simply left unchanged - if you |
|
99 |
write your application in (say) english, and only plan to use it in english, |
|
5653 | 100 |
no additional work is required (i.e you don't even need a resource file then). |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
101 |
Strings for unknown languages will come in english |
145 | 102 |
(which is better than nothing or empty button labels ;-) |
103 |
||
7649 | 104 |
Notice, that you can also translate english to english, by providing an en.rs file. |
5653 | 105 |
This is sometimes useful to fix typing errors or bad syntax in the english, |
106 |
as sometimes made by the programmer, without a need to recompile or to also adjust other |
|
107 |
language translations. |
|
108 |
||
109 |
Finally, this scheme is also compatible to a pure enum-key based translation mechanism, |
|
110 |
as typically used in the C-world. |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
111 |
Simple use keys as argument, and provide translations for all languages (incl. english). |
5653 | 112 |
For example: |
7649 | 113 |
Button label:(resources string:#BTN_FOO_LABEL) |
5653 | 114 |
|
115 |
||
145 | 116 |
Summary: |
7649 | 117 |
in subclasses of View and ApplicationModel, instead of writing: |
145 | 118 |
|
7649 | 119 |
... |
120 |
b := Button label:'press me' |
|
121 |
... |
|
145 | 122 |
|
7649 | 123 |
always write: |
612 | 124 |
|
7649 | 125 |
... |
126 |
b := Button label:(resources string:'press me') |
|
127 |
... |
|
145 | 128 |
|
7649 | 129 |
if your class is not a subclass of one of the above, AND you need |
130 |
resource translations, you won't inherit the resources variable |
|
131 |
(which is automatically initialized). |
|
132 |
In this case, you have to ask the ResourcePack class explicitely for |
|
133 |
a corresponding package: |
|
5483 | 134 |
|
7649 | 135 |
ResourcePack for:aClassName |
136 |
or (even better): |
|
137 |
ResourcePack forPackage:aPackageID |
|
145 | 138 |
|
7649 | 139 |
as an example, see how the Date class gets the national names of |
140 |
week & monthnames. |
|
145 | 141 |
|
5483 | 142 |
Debugging: |
7649 | 143 |
in the past, it happened that strings as returned by me were modified by someone else |
144 |
(replaceAll:with:) and then lead to invalid presentation in the future. |
|
145 |
To detect any bad guy which writes into one of my returned strings, set the DebugModifications |
|
146 |
classVar to true. Then I will return ImmutableStrings which trap on writes. |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
147 |
|
612 | 148 |
[author:] |
7649 | 149 |
Claus Gittinger |
145 | 150 |
" |
151 |
! |
|
152 |
||
153 |
examples |
|
154 |
" |
|
8627 | 155 |
normally, resources are found in files named after their classes sourcefile, |
156 |
or in 'resources.rs' under the package's 'resources' folder. |
|
157 |
||
158 |
For example, the FileBrowsers resources might be found in 'FBrowser.rs', |
|
159 |
or in the package's summary resources 'libwidg/resources/resources.rs'. |
|
160 |
||
161 |
Notice: |
|
162 |
in previous older ST/X versions, there where individual resource files as per class; |
|
163 |
this lead to many duplicate entries and many small resource files. |
|
164 |
Therefore, these have been concentrated into one resource file as per package, |
|
165 |
which typically dispatches to a specific resource files named <lang>.rs. |
|
166 |
See the libwidg/resources or libview/resources folders as examples. |
|
167 |
||
145 | 168 |
For the examples below, we process resources from a constant string; |
8462 | 169 |
this is NOT representative. |
170 |
[exBegin] |
|
171 |
|stream res| |
|
145 | 172 |
|
8462 | 173 |
stream := ReadStream on:' |
145 | 174 |
foo ''the translation for foo'' |
3422 | 175 |
#if Language == #de |
145 | 176 |
bar ''die deutsche uebersetzung von bar'' |
177 |
baz ''baz hat den Wert %1'' |
|
178 |
#endif |
|
3422 | 179 |
#if Language == #fr |
145 | 180 |
bar ''bar en francaise'' |
181 |
baz ''%1, c''''est baz'' |
|
182 |
#endif |
|
183 |
||
184 |
'. |
|
185 |
||
8462 | 186 |
res := ResourcePack new readFromResourceStream:stream in:nil. |
145 | 187 |
|
8462 | 188 |
Transcript showCR:'baz is translated to: ' , (res string:'baz' with:'1234'). |
189 |
Transcript showCR:'bar is translated to: ' , (res string:'bar'). |
|
190 |
Transcript showCR:'foo is translated to: ' , (res string:'foo'). |
|
191 |
Transcript showCR:'fooBar is translated to: ' , (res string:'fooBar'). |
|
192 |
[exEnd] |
|
145 | 193 |
set the Language to french: |
8462 | 194 |
[exBegin] |
195 |
Language := #fr |
|
196 |
[exEnd] |
|
145 | 197 |
and repeat the above. |
620 | 198 |
back to english: |
8462 | 199 |
[exBegin] |
200 |
Language := #en |
|
201 |
[exEnd] |
|
620 | 202 |
back to german: |
8462 | 203 |
[exBegin] |
204 |
Language := #de |
|
205 |
[exEnd] |
|
46 | 206 |
" |
207 |
! ! |
|
5 | 208 |
|
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
209 |
!ResourcePack class methodsFor:'initialization'! |
0 | 210 |
|
72 | 211 |
flushCachedResourcePacks |
24 | 212 |
"forget all cached resources - needed after a style change" |
213 |
||
8509 | 214 |
Packs := FailedToLoadPacks := nil. |
8633 | 215 |
self initialize. |
24 | 216 |
|
4093 | 217 |
" |
218 |
ResourcePack flushCachedResourcePacks |
|
219 |
" |
|
8633 | 220 |
|
221 |
"Modified: / 21-02-2019 / 14:55:45 / Claus Gittinger" |
|
244 | 222 |
! |
223 |
||
224 |
initialize |
|
225 |
Packs isNil ifTrue:[ |
|
8510 | 226 |
Packs := WeakArray new:50. |
8462 | 227 |
FailedToLoadPacks := Set new. |
244 | 228 |
]. |
229 |
||
4093 | 230 |
" |
231 |
ResourcePack initialize |
|
8510 | 232 |
ResourcePack flushCachedResourcePacks. |
233 |
ApplicationModel flushAllClassResources. |
|
234 |
SimpleView flushAllClassResources. |
|
235 |
||
236 |
SimpleView classResources |
|
4093 | 237 |
" |
4623 | 238 |
|
5826
c4ed474970c1
forPackage:resourceFileName:cached:
Claus Gittinger <cg@exept.de>
parents:
5781
diff
changeset
|
239 |
"Modified: / 28-09-2011 / 15:53:21 / cg" |
244 | 240 |
! ! |
241 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
242 |
!ResourcePack class methodsFor:'instance creation'! |
244 | 243 |
|
8520 | 244 |
addAdditionalSuperPacksForPackage:packageID to:resourcePack |
245 |
|prjDefinition| |
|
8517 | 246 |
|
8520 | 247 |
prjDefinition := ProjectDefinition definitionClassForPackage:packageID. |
248 |
prjDefinition notNil ifTrue:[ |
|
249 |
(prjDefinition additionalClassResources ? #()) do:[:each | |
|
250 |
resourcePack addSuperPack:each |
|
251 |
] |
|
8517 | 252 |
]. |
253 |
! |
|
254 |
||
244 | 255 |
for:aClass |
256 |
"get the full resource definitions for aClass (i.e. with super packs). |
|
257 |
Also leave the resulting pack in the cache for faster access next time." |
|
258 |
||
4619 | 259 |
^ self for:aClass cached:false |
4030 | 260 |
|
261 |
" |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
262 |
ResourcePack for:TextView |
4030 | 263 |
ResourcePack for:CodeView |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
264 |
ResourcePack for:Workspace |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
265 |
ResourcePack for:View |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
266 |
ResourcePack for:ErrorLogger |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
267 |
ResourcePack for:NewLauncher |
6799 | 268 |
ResourcePack for:SmallSense::SettingsAppl |
4030 | 269 |
Workspace classResources |
270 |
" |
|
4619 | 271 |
|
272 |
"Modified: / 18-09-2006 / 19:02:57 / cg" |
|
4030 | 273 |
! |
274 |
||
275 |
for:aClass cached:cached |
|
276 |
"get the full resource definitions for aClass (i.e. with super packs). |
|
277 |
Also leave the resulting pack in the cache for faster access next time." |
|
278 |
||
8522 | 279 |
^ self forPackage:(aClass package) cached:cached. |
8520 | 280 |
|
8510 | 281 |
"/ |nm pack rsrcDir baseName| |
282 |
"/ |
|
283 |
"/ nm := aClass resourcePackName. |
|
284 |
"/ cached ifTrue:[ |
|
285 |
"/ pack := self searchCacheFor:nm. |
|
286 |
"/ pack notNil ifTrue:[^ pack]. |
|
287 |
"/ ]. |
|
288 |
"/ |
|
289 |
"/ baseName := (Smalltalk fileNameForClass:nm) , '.rs'. |
|
290 |
"/ rsrcDir := aClass resourceDirectory. |
|
291 |
"/ |
|
292 |
"/"/ CHECK this |
|
293 |
"/"/ (rsrcDir notNil and:[rsrcDir suffix = 'rs']) ifTrue:[ |
|
294 |
"/"/ baseName := (Smalltalk fileNameForClass: rsrcDir tail asFilename withoutSuffix pathName),'.rs'. |
|
295 |
"/"/ rsrcDir := rsrcDir head asFilename. |
|
296 |
"/"/ ]. |
|
297 |
"/ |
|
298 |
"/ rsrcDir notNil ifTrue:[ |
|
299 |
"/ pack := self new. |
|
300 |
"/ rsrcDir exists ifTrue:[ |
|
301 |
"/ (rsrcDir construct:baseName) exists ifTrue:[ |
|
302 |
"/ pack := self fromFile:baseName directory:(rsrcDir name) cached:cached. |
|
303 |
"/ ]. |
|
304 |
"/ ] |
|
305 |
"/ ] ifFalse:[ |
|
306 |
"/ pack := self fromFile:baseName directory:'resources' cached:cached. |
|
307 |
"/ ]. |
|
308 |
"/ aClass superclass notNil ifTrue:[ |
|
309 |
"/ pack superPack:(self for:(aClass superclass) cached:cached). |
|
310 |
"/ ]. |
|
311 |
"/ pack packsClassOrFileName:nm. |
|
312 |
"/ cached ifTrue:[ |
|
313 |
"/ self addToCache:pack. |
|
314 |
"/ ]. |
|
315 |
"/ pack projectPack:(self forPackage:(aClass resourcePackage) cached:cached). |
|
316 |
"/ ^ pack |
|
244 | 317 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
318 |
" |
4656 | 319 |
ResourcePack forPackage:'bosch:dapasx' cached:true |
320 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
321 |
ResourcePack for:TextView |
244 | 322 |
ResourcePack for:CodeView |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
323 |
ResourcePack for:Workspace |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
324 |
ResourcePack for:View |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
325 |
ResourcePack for:ErrorLogger |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
326 |
ResourcePack for:NewLauncher |
244 | 327 |
Workspace classResources |
328 |
" |
|
4617 | 329 |
|
5642
494cea2296dc
comment/format in: #for:cached:
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
330 |
"Modified: / 01-11-2010 / 09:09:43 / cg" |
8522 | 331 |
"Modified: / 16-10-2018 / 17:12:25 / Stefan Vogel" |
244 | 332 |
! |
333 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
334 |
forPackage:package |
4078 | 335 |
"get the full resource definitions given a package id (such as stx:libbasic'). |
336 |
Also leave the resulting pack in the cache for faster access next time." |
|
337 |
||
338 |
^ self forPackage:package cached:true |
|
339 |
||
340 |
" |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
341 |
ResourcePack forPackage:'stx:libbasic' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
342 |
ResourcePack forPackage:'stx:libtool' |
8509 | 343 |
ResourcePack forPackage:'stx:libView' |
4078 | 344 |
" |
4618 | 345 |
|
346 |
"Modified: / 18-09-2006 / 18:45:31 / cg" |
|
4078 | 347 |
! |
348 |
||
349 |
forPackage:package cached:cached |
|
350 |
"get the full resource definitions given a package id (such as stx:libbasic'). |
|
351 |
Also optionally leave the resulting pack in the cache for faster access next time." |
|
352 |
||
8599 | 353 |
|pack lang territory| |
354 |
||
355 |
pack := self forPackage:package resourceFileName:'resources.rs' cached:cached defaultIfAbsent:false. |
|
356 |
pack isNil ifTrue:[ |
|
357 |
lang := Smalltalk language. |
|
358 |
territory := Smalltalk languageTerritory. |
|
359 |
pack := self forPackage:package resourceFileName:(lang,'_',territory,'.rs') cached:cached defaultIfAbsent:false. |
|
360 |
pack isNil ifTrue:[ |
|
361 |
pack := self forPackage:package resourceFileName:(lang,'.rs') cached:cached defaultIfAbsent:false. |
|
362 |
pack isNil ifTrue:[ |
|
363 |
pack := self newDefaultResourcePackForPackage:package. |
|
364 |
self addAdditionalSuperPacksForPackage:package to:pack. |
|
365 |
]. |
|
366 |
] |
|
367 |
]. |
|
368 |
^ pack |
|
369 |
||
4673 | 370 |
" |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
371 |
ResourcePack forPackage:'stx:libbasic' cached:false |
8599 | 372 |
ResourcePack forPackage:'exept:expecco/plugin/windowsAutomation2' cached:false |
4673 | 373 |
" |
374 |
||
375 |
"Modified: / 19-10-2006 / 23:18:28 / cg" |
|
8599 | 376 |
"Modified: / 13-12-2018 / 13:24:56 / Claus Gittinger" |
4673 | 377 |
! |
378 |
||
379 |
forPackage:package resourceFileName:resourceFileName cached:cached |
|
380 |
"get the full resource definitions given a package id (such as stx:libbasic'). |
|
5826
c4ed474970c1
forPackage:resourceFileName:cached:
Claus Gittinger <cg@exept.de>
parents:
5781
diff
changeset
|
381 |
Also optionally leave the resulting pack in the cache for faster access next time. |
c4ed474970c1
forPackage:resourceFileName:cached:
Claus Gittinger <cg@exept.de>
parents:
5781
diff
changeset
|
382 |
Remember failed packs, to avoid retrying reading the file again and again" |
4673 | 383 |
|
8599 | 384 |
^ self |
385 |
forPackage:package |
|
386 |
resourceFileName:resourceFileName |
|
387 |
cached:cached |
|
388 |
defaultIfAbsent:true |
|
389 |
||
390 |
" |
|
391 |
ResourcePack flushCachedResourcePacks. |
|
392 |
||
393 |
ResourcePack |
|
394 |
forPackage:'stx:libbasic' |
|
395 |
resourceFileName:'resources.rs' |
|
396 |
cached:false |
|
397 |
" |
|
398 |
||
399 |
"Modified: / 28-09-2011 / 15:55:30 / cg" |
|
400 |
"Modified: / 13-12-2018 / 13:17:00 / Claus Gittinger" |
|
401 |
! |
|
402 |
||
403 |
forPackage:package resourceFileName:resourceFileName cached:cached defaultIfAbsent:defaultIfAbsentBoolean |
|
404 |
"get the full resource definitions given a package id (such as stx:libbasic'). |
|
405 |
Also optionally leave the resulting pack in the cache for faster access next time. |
|
406 |
Remember failed packs, to avoid retrying reading the file again and again" |
|
407 |
||
4428 | 408 |
|fullName pack rsrcDir file| |
4078 | 409 |
|
8517 | 410 |
package isNil ifTrue:[ |
8637 | 411 |
"/ '[ResourcePack] warning: nil package asking for resource file'. |
8599 | 412 |
defaultIfAbsentBoolean ifFalse:[^ nil]. |
8544 | 413 |
^ self newDefaultResourcePackForPackage:package |
8517 | 414 |
]. |
415 |
||
8510 | 416 |
fullName := (package copyReplaceAll:$: with:$/),'/resources/',resourceFileName. |
4078 | 417 |
|
418 |
cached ifTrue:[ |
|
8462 | 419 |
pack := self searchCacheFor:fullName. |
420 |
pack notNil ifTrue:[^ pack]. |
|
8520 | 421 |
|
8517 | 422 |
(FailedToLoadPacks includes:fullName) ifTrue:[ |
8520 | 423 |
"/ it already failed to load - do not try again |
8599 | 424 |
defaultIfAbsentBoolean ifFalse:[^ nil]. |
8544 | 425 |
pack := self newDefaultResourcePackForPackage:package. |
8520 | 426 |
self addAdditionalSuperPacksForPackage:package to:pack. |
427 |
^ pack |
|
8517 | 428 |
]. |
4078 | 429 |
]. |
430 |
||
8510 | 431 |
"/ Smalltalk projectDirectoryForPackage:'stx:libview' |
4078 | 432 |
rsrcDir := Smalltalk projectDirectoryForPackage:package. |
8514 | 433 |
"/ '1) projectDirectoryForPackage -> ' print. |
434 |
"/ rsrcDir printCR. |
|
8517 | 435 |
rsrcDir notNil ifTrue:[ |
436 |
rsrcDir := rsrcDir asFilename / 'resources'. |
|
8514 | 437 |
"/ '3) rsrcDir -> ' print. |
438 |
"/ rsrcDir printCR. |
|
8517 | 439 |
rsrcDir exists ifTrue:[ |
8599 | 440 |
(rsrcDir / resourceFileName) exists ifTrue:[ |
441 |
pack := self fromFile:resourceFileName directory:rsrcDir cached:cached. |
|
442 |
pack packsPackage:package. |
|
443 |
self addAdditionalSuperPacksForPackage:package to:pack. |
|
444 |
^ pack |
|
445 |
]. |
|
8462 | 446 |
]. |
8517 | 447 |
]. |
448 |
||
449 |
file := Smalltalk getResourceFileName:resourceFileName forPackage:package. |
|
8519 | 450 |
(file notNil and:[(file := file asFilename) exists]) ifTrue:[ |
451 |
rsrcDir := file directory. |
|
8517 | 452 |
pack := self fromFile:resourceFileName directory:rsrcDir cached:cached. |
453 |
pack packsPackage:package. |
|
8520 | 454 |
self addAdditionalSuperPacksForPackage:package to:pack. |
8517 | 455 |
^ pack |
4428 | 456 |
]. |
8517 | 457 |
|
458 |
FailedToLoadPacks add:fullName. |
|
8599 | 459 |
defaultIfAbsentBoolean ifFalse:[^ nil]. |
8544 | 460 |
pack := self newDefaultResourcePackForPackage:package. |
8520 | 461 |
self addAdditionalSuperPacksForPackage:package to:pack. |
462 |
^ pack |
|
4078 | 463 |
|
464 |
" |
|
8517 | 465 |
ResourcePack flushCachedResourcePacks. |
466 |
||
8510 | 467 |
ResourcePack |
468 |
forPackage:'stx:libbasic' |
|
469 |
resourceFileName:'resources.rs' |
|
470 |
cached:false |
|
4078 | 471 |
" |
4656 | 472 |
|
8599 | 473 |
"Created: / 13-12-2018 / 13:16:36 / Claus Gittinger" |
4078 | 474 |
! |
475 |
||
244 | 476 |
fromFile:aFileName |
4611 | 477 |
"get the resource definitions from a file in the default directory." |
244 | 478 |
|
479 |
^ self fromFile:aFileName directory:'resources' |
|
480 |
||
481 |
" |
|
482 |
ResourcePack fromFile:'SBrowser.rs' |
|
483 |
ResourcePack fromFile:'FBrowser.rs' |
|
484 |
ResourcePack fromFile:'Smalltalk.rs' |
|
3678 | 485 |
ResourcePack fromFile:'Smalltalk.rs' asFilename |
3983 | 486 |
ResourcePack fromFile:'../../libtool/resources/AboutBox_ru.rs' asFilename |
244 | 487 |
" |
488 |
! |
|
489 |
||
490 |
fromFile:aFileName directory:dirName |
|
4611 | 491 |
"get the resource definitions from a file in a directory." |
492 |
||
493 |
^ self fromFile:aFileName directory:dirName cached:false |
|
494 |
! |
|
495 |
||
496 |
fromFile:aFileName directory:dirName cached:cached |
|
244 | 497 |
"get the resource definitions from a file in a directory. |
498 |
Uncached low-level entry." |
|
499 |
||
8483 | 500 |
|cachedPack newPack fn| |
244 | 501 |
|
8483 | 502 |
fn := (dirName asFilename / aFileName) pathName. |
503 |
cachedPack := Packs detect:[:p | p notNil and:[p isInteger not and:[p packsFileName = fn]]] ifNone:nil. |
|
504 |
cachedPack notNil ifTrue:[ |
|
505 |
"/ Transcript showCR:'cached pack: ',fn asString. |
|
506 |
^ cachedPack |
|
507 |
]. |
|
508 |
||
244 | 509 |
newPack := self new. |
7388 | 510 |
KeepStatisticsOnUsedKeys == true ifTrue:[ |
511 |
newPack rememberUsedKeys. |
|
512 |
]. |
|
8514 | 513 |
"/ '5) file ' print. aFileName print. |
514 |
"/ ' in ' print. dirName printCR. |
|
244 | 515 |
newPack readFromFile:aFileName directory:dirName. |
4611 | 516 |
cached ifTrue:[ |
7388 | 517 |
self addToCache:newPack. |
4611 | 518 |
]. |
244 | 519 |
^ newPack |
8483 | 520 |
|
521 |
"Modified: / 25-09-2018 / 09:57:42 / Claus Gittinger" |
|
8520 | 522 |
! |
523 |
||
8546 | 524 |
newDefaultResourcePackForPackage:package |
8548 | 525 |
|rsrcs superPack| |
8520 | 526 |
|
527 |
rsrcs := ResourcePack new. |
|
8546 | 528 |
|
8548 | 529 |
package = 'stx:libtool' ifTrue:[ |
530 |
superPack := self forPackage:'stx:libview'. |
|
531 |
superPack notNil ifTrue:[ rsrcs addSuperPack:superPack ]. |
|
8544 | 532 |
]. |
533 |
^ rsrcs |
|
534 |
||
535 |
"Created: / 24-10-2018 / 18:07:25 / Claus Gittinger" |
|
8548 | 536 |
"Modified: / 25-10-2018 / 02:36:04 / Claus Gittinger" |
0 | 537 |
! ! |
538 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
539 |
!ResourcePack class methodsFor:'private'! |
54 | 540 |
|
541 |
addToCache:aPack |
|
542 |
|idx| |
|
0 | 543 |
|
4084 | 544 |
Packs isNil ifTrue:[ |
8462 | 545 |
self initialize. |
4084 | 546 |
]. |
547 |
||
54 | 548 |
idx := Packs identityIndexOf:nil. |
549 |
idx == 0 ifTrue:[ |
|
8462 | 550 |
idx := Packs findFirst:[:slot | slot class == SmallInteger]. |
1078
f7b6f15899ab
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
551 |
]. |
f7b6f15899ab
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
552 |
idx == 0 ifTrue:[ |
8462 | 553 |
" |
554 |
throw away oldest |
|
555 |
" |
|
556 |
idx := Packs size. |
|
557 |
Packs replaceFrom:1 to:idx-1 with:Packs startingAt:2. |
|
54 | 558 |
]. |
5357 | 559 |
aPack at:'__language__' put:(UserPreferences current language,'_',UserPreferences current languageTerritory). |
4619 | 560 |
Packs at:idx put:aPack. |
561 |
||
562 |
"Modified: / 18-09-2006 / 19:12:12 / cg" |
|
54 | 563 |
! |
0 | 564 |
|
8517 | 565 |
searchCacheFor:aPackageName |
4619 | 566 |
|sz "{ Class: SmallInteger }" lang| |
0 | 567 |
|
24 | 568 |
Packs isNil ifTrue:[ |
8462 | 569 |
self initialize. |
570 |
^ nil |
|
0 | 571 |
]. |
54 | 572 |
|
5357 | 573 |
lang := (UserPreferences current language,'_',UserPreferences current languageTerritory). |
4619 | 574 |
|
54 | 575 |
sz := Packs size. |
576 |
1 to:sz do:[:idx | |
|
8462 | 577 |
|aPack| |
54 | 578 |
|
8462 | 579 |
aPack := Packs at:idx. |
580 |
(aPack notNil and:[aPack class ~~ SmallInteger]) ifTrue:[ |
|
581 |
(aPack at:'__language__' ifAbsent:nil) = lang ifTrue:[ |
|
8517 | 582 |
aPackageName = aPack packsPackage ifTrue:[ |
8462 | 583 |
" |
584 |
bring to front for LRU |
|
585 |
" |
|
586 |
idx ~~ 1 ifTrue:[ |
|
587 |
Packs replaceFrom:2 to:idx with:Packs startingAt:1. |
|
588 |
Packs at:1 put:aPack. |
|
589 |
]. |
|
590 |
^ aPack |
|
591 |
] |
|
592 |
] |
|
593 |
] |
|
0 | 594 |
]. |
54 | 595 |
^ nil |
123 | 596 |
|
597 |
" |
|
8517 | 598 |
ResourcePack searchCacheFor:'stx:libview' |
123 | 599 |
" |
4619 | 600 |
|
601 |
"Modified: / 18-09-2006 / 19:13:13 / cg" |
|
54 | 602 |
! ! |
603 |
||
4509 | 604 |
!ResourcePack class methodsFor:'utilities'! |
605 |
||
8633 | 606 |
defineResourceFor:aKey package:package |
607 |
"a developer utility: |
|
608 |
ask for a resource string and add it to package's resources. |
|
609 |
Called via CTRL-menu of labels" |
|
610 |
||
611 |
|resources language toTry alreadyTried foundResourceFile answer translation out| |
|
612 |
||
613 |
resources := self forPackage:package cached:false. |
|
614 |
resources isNil ifTrue:[ |
|
615 |
Dialog information:'No resource pack found for package "%1"' with:package. |
|
616 |
FileBrowser default openOnDirectory:(package asPackageId packageDirectory). |
|
617 |
^ self. |
|
618 |
]. |
|
619 |
||
620 |
(language := LastLanguageChosen) isNil ifTrue:[ |
|
621 |
language := resources localAt:'__language__'. |
|
622 |
language isNil ifTrue:[language := Smalltalk language]. |
|
623 |
]. |
|
624 |
language := Dialog request:('Language for key: "%1"' bindWith:(aKey contractTo:60)) initialAnswer:language. |
|
625 |
language isNil ifTrue:[^ self]. |
|
626 |
||
627 |
LastLanguageChosen := language. |
|
628 |
||
629 |
toTry := OrderedCollection with:resources. |
|
630 |
alreadyTried := OrderedCollection with:resources. |
|
631 |
||
632 |
Transcript showCR:'searching for existing resource file...'. |
|
633 |
"/ find a resourcepack with this language in it |
|
634 |
foundResourceFile := nil. |
|
635 |
[toTry notEmpty and:[foundResourceFile isNil]] whileTrue:[ |
|
636 |
|triedResources thisResourceFile thisResourceDir triedResourceFile| |
|
637 |
||
638 |
triedResources := toTry removeFirst. |
|
639 |
alreadyTried add:resources. |
|
640 |
||
641 |
thisResourceFile := triedResources packsFileName asFilename. |
|
642 |
thisResourceDir := thisResourceFile directory. |
|
643 |
triedResourceFile := thisResourceDir / (language,'.rs'). |
|
644 |
(triedResourceFile exists) ifTrue:[ |
|
645 |
foundResourceFile := triedResourceFile. |
|
646 |
] ifFalse:[ |
|
647 |
toTry addAll:[triedResources superPacks reject:[:p | alreadyTried includes:p]]. |
|
648 |
]. |
|
649 |
]. |
|
650 |
foundResourceFile isNil ifTrue:[ |
|
651 |
Dialog information:('No resource pack found for package "%1" and language "%2"' bindWith:package with:language). |
|
652 |
FileBrowser default openOnDirectory:(package asPackageId packageDirectory). |
|
653 |
^ self. |
|
654 |
]. |
|
655 |
||
656 |
(foundResourceFile contents |
|
657 |
contains:[:line | line includesString:aKey]) ifTrue:[ |
|
658 |
Dialog information:('Resource file seems to already contain this or a similar translation'). |
|
659 |
(FileBrowser default openOn:foundResourceFile) |
|
660 |
openTextEditorForFile:foundResourceFile. |
|
661 |
^ self. |
|
662 |
]. |
|
663 |
||
664 |
answer := Dialog confirmWithCancel:('Add to file "%1"?' bindWith:foundResourceFile). |
|
665 |
answer isNil ifTrue:[^ self]. |
|
666 |
answer ifFalse:[ |
|
667 |
FileBrowser default openOn:foundResourceFile. |
|
668 |
^ self. |
|
669 |
]. |
|
670 |
||
8635 | 671 |
translation := Dialog request:('Translation of "%1"?\(in "%2")' withCRs bindWith:aKey with:foundResourceFile) |
8633 | 672 |
initialAnswer:aKey. |
673 |
translation isEmptyOrNil ifTrue:[^ self]. |
|
674 |
||
675 |
Transcript showCR:'rewriting %1...' with:foundResourceFile. |
|
676 |
||
677 |
[ |
|
678 |
out := foundResourceFile appendingWriteStream. |
|
679 |
out nextPutLine:''. |
|
680 |
out nextPutLine:(aKey storeString,Character tab,translation storeString). |
|
681 |
] ensure:[ |
|
682 |
out close |
|
683 |
]. |
|
684 |
||
685 |
"/ flush the resources... |
|
686 |
Transcript showCR:'flushing cached resources...'. |
|
687 |
self flushCachedResourcePacks. |
|
688 |
||
689 |
Transcript showCR:'simulating a language change...'. |
|
690 |
Smalltalk changed:#Language. "this flushes everything" |
|
691 |
||
692 |
"Created: / 21-02-2019 / 14:23:57 / Claus Gittinger" |
|
8635 | 693 |
"Modified: / 22-02-2019 / 09:46:04 / Claus Gittinger" |
8633 | 694 |
! |
695 |
||
4509 | 696 |
extractEncodingFromLine:lineString |
697 |
|rest encoding| |
|
698 |
||
699 |
(lineString startsWith:'encoding') ifFalse:[^ nil]. |
|
700 |
||
701 |
rest := lineString copyFrom:9. |
|
702 |
rest := rest withoutSeparators. |
|
703 |
(rest startsWith:'#') ifTrue:[ |
|
8462 | 704 |
rest := rest copyFrom:2. |
4509 | 705 |
]. |
706 |
(rest startsWith:'''') ifTrue:[ |
|
8462 | 707 |
rest := rest copyFrom:2. |
708 |
(rest endsWith:'''') ifTrue:[ |
|
709 |
rest := rest copyButLast:1. |
|
710 |
]. |
|
4509 | 711 |
]. |
712 |
encoding := rest asSymbol. |
|
713 |
^ encoding. |
|
714 |
! |
|
715 |
||
716 |
processResourceLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError for:aResourcePack |
|
717 |
"process a single valid line (i.e. #ifdef & #include has already been processed)" |
|
718 |
||
4510 | 719 |
self |
8462 | 720 |
processResourceLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError for:aResourcePack |
721 |
keepUselessTranslations:false. |
|
4510 | 722 |
! |
723 |
||
724 |
processResourceLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError for:aResourcePack keepUselessTranslations:keepUselessTranslations |
|
725 |
"process a single valid line (i.e. #ifdef & #include has already been processed)" |
|
726 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
727 |
|name lineStream idx rest macroName value |
4670 | 728 |
conditional hasError decoder oldValue ignoreTranslation indirect| |
4509 | 729 |
|
6250 | 730 |
"/ Transcript showCR:lineString. |
4531 | 731 |
encodingSymbolOrEncoder notNil ifTrue:[ |
8462 | 732 |
encodingSymbolOrEncoder isSymbol ifTrue:[ |
733 |
decoder := CharacterEncoder encoderFor:encodingSymbolOrEncoder ifAbsent:nil. |
|
734 |
decoder isNil ifTrue:[ decoder := CharacterEncoder nullEncoderInstance ]. |
|
735 |
] ifFalse:[ |
|
736 |
decoder := encodingSymbolOrEncoder |
|
737 |
]. |
|
4531 | 738 |
]. |
739 |
||
740 |
decoder notNil ifTrue:[ |
|
8462 | 741 |
lineStream := (decoder decodeString:lineString) readStream. |
4531 | 742 |
] ifFalse:[ |
8462 | 743 |
lineStream := lineString readStream. |
4531 | 744 |
]. |
4509 | 745 |
lineStream signalAtEnd:false. |
746 |
lineStream skipSeparators. |
|
5080 | 747 |
|
4509 | 748 |
lineStream peek == $# ifTrue:[ |
8462 | 749 |
name := Array |
750 |
readFrom:lineStream |
|
751 |
onError:[ |
|
752 |
printError value:('invalid line <' , lineString , '>'). |
|
753 |
nil |
|
754 |
]. |
|
4509 | 755 |
] ifFalse:[ |
8462 | 756 |
lineStream peek == $' ifTrue:[ |
757 |
name := String |
|
758 |
readSmalltalkStringFrom:lineStream |
|
759 |
onError:[ |
|
760 |
printError value:('invalid line <' , lineString , '>'). |
|
761 |
nil |
|
762 |
]. |
|
763 |
] ifFalse:[ |
|
764 |
name := lineStream upToSeparator. |
|
765 |
]. |
|
4509 | 766 |
]. |
767 |
||
4510 | 768 |
name isNil ifTrue:[^ self ]. |
769 |
||
770 |
ignoreTranslation := false. |
|
771 |
hasError := false. |
|
4509 | 772 |
|
4510 | 773 |
lineStream skipSeparators. |
6113 | 774 |
idx := lineStream position + 1 + 1. |
4510 | 775 |
|
776 |
lineStream peek == $< ifTrue:[ |
|
8462 | 777 |
" |
778 |
skip <type> if present |
|
779 |
" |
|
780 |
lineStream skipThrough:$>. |
|
781 |
lineStream skipSeparators. |
|
782 |
idx := lineStream position + 2. |
|
4510 | 783 |
]. |
4509 | 784 |
|
4670 | 785 |
conditional := indirect := false. |
4510 | 786 |
lineStream peek == $? ifTrue:[ |
8462 | 787 |
conditional := true. |
788 |
lineStream next. |
|
789 |
lineStream skipSeparators. |
|
4670 | 790 |
]. |
791 |
||
792 |
lineStream peek == $@ ifTrue:[ |
|
8462 | 793 |
indirect := true. |
794 |
lineStream next. |
|
795 |
lineStream skipSeparators. |
|
4510 | 796 |
]. |
4509 | 797 |
|
4510 | 798 |
lineStream peek == $= ifTrue:[ |
8462 | 799 |
lineStream next. |
4510 | 800 |
|
8462 | 801 |
macroName := lineStream nextAlphaNumericWord. |
802 |
[lineStream peek == $.] whileTrue:[ |
|
803 |
lineStream next. |
|
804 |
lineStream peek notNil ifTrue:[ |
|
805 |
macroName := macroName , '.' , (lineStream nextAlphaNumericWord) |
|
806 |
] |
|
807 |
]. |
|
808 |
rest := lineStream upToEnd. |
|
809 |
value := aResourcePack at:macroName ifAbsent:nil. |
|
810 |
(value isNil) ifTrue:[ |
|
811 |
hasError := true. |
|
812 |
printError value:('bad (nil-valued) macro: ' , macroName). |
|
813 |
]. |
|
4678
0d83cc874dc3
block value handling changed
Claus Gittinger <cg@exept.de>
parents:
4673
diff
changeset
|
814 |
"/ value isBlock ifTrue:[ |
0d83cc874dc3
block value handling changed
Claus Gittinger <cg@exept.de>
parents:
4673
diff
changeset
|
815 |
"/ value := value value |
0d83cc874dc3
block value handling changed
Claus Gittinger <cg@exept.de>
parents:
4673
diff
changeset
|
816 |
"/ ]. |
8462 | 817 |
rest isBlank ifFalse:[ |
818 |
value := Compiler evaluate:('self ' , rest) |
|
819 |
receiver:value |
|
820 |
notifying:nil |
|
821 |
compile:false. |
|
822 |
(value == #Error) ifTrue:[ |
|
823 |
hasError := true. |
|
824 |
printError value:('error in: "self ' , rest , '"'). |
|
825 |
]. |
|
826 |
"/ 'self ' print. rest print. ' -> ' print. value printCR. |
|
827 |
] |
|
4510 | 828 |
] ifFalse:[ |
8462 | 829 |
lineStream peek == $' ifTrue:[ |
830 |
value := String |
|
831 |
readSmalltalkStringFrom:lineStream |
|
832 |
onError:[ |
|
833 |
printError value:('invalid line <' , lineString , '>'). |
|
834 |
nil |
|
835 |
]. |
|
836 |
"/ ' -> ' print. value printCR. |
|
837 |
] ifFalse:[ |
|
838 |
rest := lineStream upToEnd. |
|
839 |
[ |
|
840 |
value := Compiler evaluate:rest compile:"true" false. |
|
841 |
] on:Error do:[ |
|
8476 | 842 |
printError value:('invalid line <' , lineString , '>'). |
8462 | 843 |
"/ value := rest |
844 |
]. |
|
845 |
"/ rest print. ' -> ' print. value printCR. |
|
846 |
]. |
|
847 |
(value == #Error) ifTrue:[ |
|
848 |
hasError := true. |
|
849 |
printError value:('error in: "' , rest , '"'). |
|
850 |
] ifFalse:[ |
|
4531 | 851 |
"/ value isString ifTrue:[ |
852 |
"/ decoder notNil ifTrue:[ |
|
853 |
"/ value := decoder decodeString:value |
|
854 |
"/ ] |
|
855 |
"/ ] |
|
8462 | 856 |
] |
4510 | 857 |
]. |
858 |
||
5430
128e9b37fd8a
comment/format in: #processResourceLine:encoding:file:printErrorWith:for:
sr
parents:
5370
diff
changeset
|
859 |
"/ Transcript show:name; show:' -> '; showCR:value. |
128e9b37fd8a
comment/format in: #processResourceLine:encoding:file:printErrorWith:for:
sr
parents:
5370
diff
changeset
|
860 |
|
4510 | 861 |
hasError ifFalse:[ |
8462 | 862 |
(conditional not |
863 |
or:[(aResourcePack includesKey:name) not]) ifTrue:[ |
|
864 |
name = value ifTrue:[ |
|
865 |
keepUselessTranslations ifFalse:[ |
|
866 |
printError value:('useless resource: "' , name , '"'). |
|
867 |
ignoreTranslation := true |
|
868 |
]. |
|
869 |
]. |
|
870 |
ignoreTranslation ifFalse:[ |
|
871 |
oldValue := aResourcePack at:name ifAbsent:nil. |
|
872 |
oldValue notNil ifTrue:[ |
|
8667 | 873 |
|fromInfo oldPack newValue| |
874 |
||
875 |
value isBlock ifTrue:[ |
|
876 |
newValue := value value |
|
877 |
] ifFalse:[ |
|
878 |
newValue := value |
|
879 |
]. |
|
8630 | 880 |
|
881 |
fromInfo := ''. |
|
882 |
oldPack := aResourcePack resourcePackContainingKey:name. |
|
883 |
oldPack ~~ aResourcePack ifTrue:[ |
|
884 |
fromInfo := ' (from ',oldPack packsFileName,')' |
|
885 |
]. |
|
886 |
||
8667 | 887 |
oldValue ~= newValue ifTrue:[ |
8462 | 888 |
printError value:('conflicting resource: "' , name , '"'). |
8630 | 889 |
printError value:(' oldValue: "%1"%2' bindWith:oldValue with:fromInfo). |
8667 | 890 |
printError value:(' newValue: "%1"' bindWith:newValue). |
8462 | 891 |
] ifFalse:[ |
8630 | 892 |
printError value:('duplicate resource: "%1"%2' bindWith:name with:fromInfo). |
8462 | 893 |
]. |
894 |
]. |
|
895 |
indirect ifTrue:[ |
|
896 |
value := aResourcePack string:value. |
|
897 |
]. |
|
5431 | 898 |
|
8667 | 899 |
"/ DebugModifications := true |
8462 | 900 |
DebugModifications == true ifTrue:[ |
901 |
"/ for debugging only !! (not all primitive code is ready for immutableStrings) |
|
902 |
value class == String ifTrue:[ |
|
903 |
value := value asImmutableString. |
|
904 |
]. |
|
905 |
]. |
|
5431 | 906 |
|
8462 | 907 |
aResourcePack at:name put:value. |
908 |
] |
|
909 |
] |
|
4509 | 910 |
] |
4534
d71ca6ac7cbe
handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents:
4531
diff
changeset
|
911 |
|
6250 | 912 |
"Modified: / 06-02-2014 / 15:33:03 / cg" |
8667 | 913 |
"Modified: / 27-03-2019 / 11:59:49 / Claus Gittinger" |
6661 | 914 |
! |
915 |
||
916 |
resourceFileEntryFor:keyString to:nationalString |
|
917 |
"generate a line for a translation file, which defines a translation |
|
918 |
from keyString to nationalString. |
|
919 |
Naivly, this could be a simple line containing the two storeStrings |
|
920 |
separated by a space. However, it is better to first cut of any leading |
|
921 |
and trailing spaces and special characters, such as ':*.,' etc." |
|
922 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
923 |
^ (self resourceFileStringFor:keyString),' ',(self resourceFileStringFor:nationalString) |
6661 | 924 |
! |
925 |
||
926 |
resourceFileStringFor:aString |
|
927 |
"generate a key or value entry for a translation file, for aString. |
|
928 |
Naivly, this could be a simple the storeString. |
|
929 |
However, it is better to first cut of any leading |
|
930 |
and trailing spaces and special characters, sch as ':*.,' etc." |
|
931 |
||
932 |
^ (self shortenedKeyFor:aString) storeString |
|
933 |
||
934 |
" |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
935 |
self resourceFileStringFor:' foo: ' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
936 |
self resourceFileStringFor:' foo bar: ' |
6661 | 937 |
" |
938 |
! |
|
939 |
||
940 |
shortenedKeyFor:aKey |
|
941 |
"if |
|
8462 | 942 |
aKey is '(...)', then return '...' |
943 |
if aKey is '[...]', then return '...' |
|
944 |
if aKey is '{...}', then return '...' |
|
945 |
if aKey starts or ends with any of '\:=.,?!! ', then return aKey without it |
|
6661 | 946 |
|
947 |
This means, that only a single translation is required to provide local translations for |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
948 |
things like |
8462 | 949 |
'search' |
950 |
'search:' |
|
951 |
'search...' |
|
6661 | 952 |
" |
953 |
||
954 |
|idx idx1 idx2 first last keySize| |
|
955 |
||
956 |
first := aKey first. |
|
957 |
last := aKey last. |
|
958 |
keySize := aKey size. |
|
959 |
||
960 |
((first == $( and:[last == $) ]) |
|
961 |
or:[ (first == $[ and:[last == $] ]) |
|
962 |
or:[ (first == ${ and:[last == $} ]) ]]) ifTrue:[ |
|
8462 | 963 |
^ self shortenedKeyFor:(aKey copyFrom:2 to:keySize-1). |
6661 | 964 |
]. |
965 |
||
966 |
idx1 := aKey findFirst:[:ch | ch isSeparator not]. |
|
967 |
idx2 := aKey findLast:[:ch | ch isSeparator not] ifNone:keySize. |
|
968 |
(idx1 > 1 or:[idx2 < keySize]) ifTrue:[ |
|
8462 | 969 |
^ self shortenedKeyFor:(aKey copyFrom:idx1 to:idx2) |
6661 | 970 |
]. |
971 |
||
972 |
idx1 := aKey findFirst:[:ch | ('*:=.?!!,-><\' includes:ch) not]. |
|
973 |
idx2 := aKey findLast:[:ch | ('*:=.?!!,-><\' includes:ch) not] ifNone:keySize. |
|
974 |
(idx1 > 1 or:[idx2 < keySize]) ifTrue:[ |
|
8462 | 975 |
^ self shortenedKeyFor:(aKey copyFrom:idx1 to:idx2) |
6661 | 976 |
]. |
977 |
||
978 |
"/ change duplicated &'s to single |
|
979 |
(idx := aKey indexOf:$&) ~~ 0 ifTrue:[ |
|
8462 | 980 |
(aKey at:idx+1 ifAbsent:nil) ~~ $& ifTrue:[ |
981 |
^ self shortenedKeyFor:(aKey copyTo:idx-1),(aKey copyFrom:idx+1). |
|
982 |
]. |
|
6661 | 983 |
]. |
984 |
^ aKey. |
|
985 |
||
986 |
" |
|
987 |
'abcde' findFirst:[:ch | 'bcd' includes:ch] |
|
988 |
'abcde' indexOfAny:'bcd' |
|
989 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
990 |
self shortenedKeyFor:'abc' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
991 |
self shortenedKeyFor:' abc ' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
992 |
self shortenedKeyFor:'(abc)' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
993 |
self shortenedKeyFor:'abc...' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
994 |
self shortenedKeyFor:'(abc...)' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
995 |
self shortenedKeyFor:'abc:*' |
6661 | 996 |
" |
4509 | 997 |
! ! |
998 |
||
0 | 999 |
!ResourcePack methodsFor:'accessing'! |
1000 |
||
244 | 1001 |
array:anArray |
1002 |
"translate a collection of strings" |
|
0 | 1003 |
|
244 | 1004 |
^ anArray collect:[:r | self at:r default:r] |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1005 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1006 |
" |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1007 |
Launcher classResources array:#('file' 'classes') |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1008 |
" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1009 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1010 |
"Modified: / 29.1.1998 / 22:44:22 / cg" |
0 | 1011 |
! |
1012 |
||
2 | 1013 |
at:aKey |
123 | 1014 |
"translate a string" |
1015 |
||
72 | 1016 |
^ self at:aKey ifAbsent:aKey |
0 | 1017 |
! |
1018 |
||
1019 |
at:aKey default:default |
|
123 | 1020 |
"translate a string" |
1021 |
||
72 | 1022 |
^ self at:aKey ifAbsent:default |
0 | 1023 |
! |
1024 |
||
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1025 |
at:aKey ifAbsent:defaultValue |
8630 | 1026 |
"translate a string; |
1027 |
search here, in my projects pack and in my superpack(s)" |
|
4617 | 1028 |
|
8630 | 1029 |
|val| |
4617 | 1030 |
|
1031 |
aKey isNil ifTrue:[ ^ defaultValue value ]. |
|
1032 |
||
8630 | 1033 |
"/ optional statistics on key usage |
8517 | 1034 |
usedKeys notNil ifTrue:[usedKeys add:aKey]. |
1035 |
||
4617 | 1036 |
val := self localAt:aKey. |
1037 |
val notNil ifTrue:[^ val]. |
|
1038 |
||
8461 | 1039 |
cache isNil ifTrue:[ cache := CacheDictionary new:1000 ]. |
1040 |
(val := cache at:aKey ifAbsent:nil) notNil ifTrue:[ |
|
1041 |
^ val |
|
1042 |
]. |
|
8630 | 1043 |
|
1044 |
self superPackHierarchyDo:[:eachPack | |
|
1045 |
val := eachPack localAt:aKey. |
|
1046 |
val notNil ifTrue:[ |
|
1047 |
cache at:aKey put:val. |
|
1048 |
^ val |
|
8461 | 1049 |
]. |
4617 | 1050 |
]. |
8510 | 1051 |
^ defaultValue value. |
4618 | 1052 |
|
1053 |
"Modified: / 18-09-2006 / 18:50:52 / cg" |
|
8630 | 1054 |
"Modified: / 20-02-2019 / 12:51:01 / Claus Gittinger" |
4617 | 1055 |
! |
1056 |
||
1057 |
localAt:aKey |
|
8630 | 1058 |
"translate a string from the local resourcePack; return nil if there is no xlation. |
4035 | 1059 |
Some special 'intelligence' has been added: |
8226 | 1060 |
if no value for aKey is found, |
8565 | 1061 |
lookup aKey with first character caseChanged and change the result's first characters case. |
1062 |
lookup aKey all lowercase and change the result's first characters case. |
|
8226 | 1063 |
or aKey is '(...)', then lookup ... wrap () around the result. |
1064 |
or aKey is '[...]', then lookup ... wrap [] around the result. |
|
1065 |
or aKey is '{...}', then lookup ... wrap {} around the result. |
|
1066 |
or aKey starts with a '\', then lookup aKey without '\' and prepend '\' to the result. |
|
1067 |
or aKey starts with a '*', then lookup aKey without '*' and prepend '*' to the result. |
|
8563 | 1068 |
or aKey starts with a '<', then lookup aKey without '<' and prepend '<' to the result. |
8639 | 1069 |
or aKey ends with ''%1'' , then lookup aKey without ''%1'' and append ''%1'' to the result. |
1070 |
or aKey ends with a '>', then lookup aKey without '>' and append '>' to the result. |
|
8226 | 1071 |
or aKey ends with a '\', then lookup aKey without '\' and append '\' to the result. |
1072 |
or aKey ends with a ':', then lookup aKey without ':' and append ':' to the result. |
|
1073 |
or aKey ends with a '=', then lookup aKey without '=' and append '=' to the result. |
|
1074 |
or aKey ends with a '.', then lookup aKey without '.' and append '.' to the result. |
|
1075 |
or aKey ends with a ',', then lookup aKey without ',' and append ',' to the result. |
|
1076 |
or aKey ends with a '?', then lookup aKey without '?' and append '?' to the result. |
|
1077 |
or aKey ends with a '!!', then lookup aKey without '!!' and append '!!' to the result. |
|
1078 |
or aKey ends with a '*', then lookup aKey without '*' and append '*' to the result. |
|
1079 |
or aKey ends with a ' ', then lookup aKey without ' ' and append ' ' to the result. |
|
1080 |
or aKey ends with a ' ...', then lookup aKey without ' ...' and append '...' to the result. |
|
1081 |
or aKey ends with a '...', then lookup aKey without '...' and append '...' to the result. |
|
1082 |
or aKey includes '&', then lookup aKey without '&'. |
|
4035 | 1083 |
|
1084 |
This means, that only a single translation is required to provide local translations for |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1085 |
things like |
8226 | 1086 |
'search' |
1087 |
'search:' |
|
1088 |
'search...' |
|
4035 | 1089 |
" |
123 | 1090 |
|
5573 | 1091 |
|val alternativeKey usedKey idx first last| |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1092 |
|
4617 | 1093 |
val := super at:aKey ifAbsent:nil. |
4678
0d83cc874dc3
block value handling changed
Claus Gittinger <cg@exept.de>
parents:
4673
diff
changeset
|
1094 |
val notNil ifTrue:[ |
8226 | 1095 |
^ val value |
4678
0d83cc874dc3
block value handling changed
Claus Gittinger <cg@exept.de>
parents:
4673
diff
changeset
|
1096 |
]. |
3549
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
1097 |
|
4848 | 1098 |
(aKey isString and:[aKey notEmpty]) ifTrue:[ |
8226 | 1099 |
first := aKey first. |
1100 |
last := aKey last. |
|
5573 | 1101 |
|
8226 | 1102 |
"/ try with case-first swapped... |
1103 |
first isLetter ifTrue:[ |
|
1104 |
alternativeKey := first isUppercase |
|
1105 |
ifTrue:[aKey asLowercaseFirst] |
|
1106 |
ifFalse:[aKey asUppercaseFirst]. |
|
1107 |
val := super at:alternativeKey ifAbsent:nil. |
|
1108 |
val notNil ifTrue:[ |
|
1109 |
first isUppercase ifTrue:[ |
|
1110 |
^ val asUppercaseFirst |
|
1111 |
]. |
|
1112 |
^ val asLowercaseFirst. |
|
1113 |
]. |
|
8565 | 1114 |
alternativeKey := aKey asLowercase. |
1115 |
val := super at:alternativeKey ifAbsent:nil. |
|
1116 |
val notNil ifTrue:[ |
|
1117 |
val first isUppercase ifTrue:[^ val]. |
|
1118 |
first isUppercase ifTrue:[ |
|
1119 |
^ val asUppercaseFirst |
|
1120 |
]. |
|
1121 |
^ val asLowercaseFirst. |
|
1122 |
]. |
|
8226 | 1123 |
]. |
4617 | 1124 |
|
8226 | 1125 |
((first == $( and:[last == $) ]) |
1126 |
or:[ (first == $[ and:[last == $] ]) |
|
1127 |
or:[ (first == ${ and:[last == $} ]) ]]) ifTrue:[ |
|
1128 |
usedKey := aKey copyFrom:2 to:aKey size-1. |
|
5593 | 1129 |
|
8226 | 1130 |
val := self localAt:usedKey. "/ recursion |
1131 |
val notNil ifTrue:[^ first asString,val,last asString]. |
|
1132 |
]. |
|
8498 | 1133 |
last == $… ifTrue:[ |
1134 |
usedKey := aKey copyButLast:1. |
|
5593 | 1135 |
|
8498 | 1136 |
val := self localAt:usedKey. "/ recursion |
1137 |
val notNil ifTrue:[^ val , '…']. |
|
1138 |
]. |
|
1139 |
||
8226 | 1140 |
last == $. ifTrue:[ |
1141 |
(aKey endsWith:' ...') ifTrue:[ |
|
1142 |
usedKey := aKey copyButLast:4. |
|
5573 | 1143 |
|
8226 | 1144 |
val := self localAt:usedKey. "/ recursion |
8498 | 1145 |
val notNil ifTrue:[^ val , '...']. |
8226 | 1146 |
]. |
1147 |
(aKey endsWith:'...') ifTrue:[ |
|
1148 |
usedKey := aKey copyButLast:3. |
|
5573 | 1149 |
|
8226 | 1150 |
val := self localAt:usedKey. "/ recursion |
1151 |
val notNil ifTrue:[^ val , '...']. |
|
1152 |
]. |
|
1153 |
]. |
|
5573 | 1154 |
|
8226 | 1155 |
first isSeparator ifTrue:[ |
1156 |
usedKey := aKey withoutLeadingSeparators. |
|
4634 | 1157 |
|
8226 | 1158 |
val := self localAt:usedKey. "/ recursion |
1159 |
val notNil ifTrue:[^ (aKey copyTo:(aKey size - usedKey size)), val]. "/ prepend the stripped separators |
|
1160 |
]. |
|
1161 |
last isSeparator ifTrue:[ |
|
1162 |
usedKey := aKey withoutTrailingSeparators. |
|
4634 | 1163 |
|
8226 | 1164 |
val := self localAt:usedKey. "/ recursion |
1165 |
val notNil ifTrue:[^ val, (aKey copyFrom:usedKey size + 1)]. "/ append the stripped separators |
|
1166 |
]. |
|
4634 | 1167 |
|
8639 | 1168 |
(aKey endsWith:'"%1"') ifTrue:[ |
1169 |
usedKey := aKey withoutSuffix:'"%1"'. |
|
1170 |
val := self localAt:usedKey. "/ recursion |
|
1171 |
val notNil ifTrue:[^ val , '"%1"']. |
|
1172 |
]. |
|
1173 |
||
8558 | 1174 |
(';*:=.?!!,-><\/' includes:last) ifTrue:[ |
8226 | 1175 |
aKey size >= 2 ifTrue:[ |
1176 |
usedKey := aKey copyButLast:1. |
|
4617 | 1177 |
|
8226 | 1178 |
val := self localAt:usedKey. "/ recursion |
1179 |
val notNil ifTrue:[^ val copyWith:last]. |
|
1180 |
]. |
|
1181 |
]. |
|
8558 | 1182 |
(';*:=.?!!-><\/' includes:first) ifTrue:[ |
8226 | 1183 |
aKey size >= 2 ifTrue:[ |
1184 |
usedKey := aKey copyButFirst:1. |
|
4634 | 1185 |
|
8226 | 1186 |
val := self localAt:usedKey. "/ recursion |
1187 |
val notNil ifTrue:[^ first asString , val]. |
|
1188 |
]. |
|
1189 |
]. |
|
4028 | 1190 |
|
8226 | 1191 |
(first == $( and:[last == $)]) ifTrue:[ |
1192 |
usedKey := aKey copyFrom:2 to:(aKey size - 1). |
|
4028 | 1193 |
|
8226 | 1194 |
val := self localAt:usedKey. "/ recursion |
1195 |
val notNil ifTrue:[^ '(' , val , ')']. |
|
1196 |
]. |
|
4017 | 1197 |
|
8226 | 1198 |
(idx := aKey indexOf:$&) ~~ 0 ifTrue:[ |
1199 |
(aKey at:idx+1 ifAbsent:nil) ~~ $& ifTrue:[ |
|
1200 |
usedKey := (aKey copyTo:idx-1) , (aKey copyFrom:idx+1). |
|
1201 |
val := self localAt:usedKey. "/ recursion |
|
1202 |
val notNil ifTrue:[^ val]. |
|
1203 |
]. |
|
1204 |
]. |
|
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1205 |
]. |
4617 | 1206 |
^ nil. |
4580 | 1207 |
|
4617 | 1208 |
"Created: / 18-09-2006 / 17:33:27 / cg" |
5593 | 1209 |
"Modified: / 05-08-2010 / 16:52:32 / sr" |
8226 | 1210 |
"Modified: / 27-11-2017 / 15:33:48 / cg" |
8639 | 1211 |
"Modified: / 27-02-2019 / 16:12:38 / Claus Gittinger" |
2 | 1212 |
! |
1213 |
||
1214 |
name:aKey default:default |
|
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1215 |
"translate a string. |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1216 |
Obsolete - use #string:default:" |
123 | 1217 |
|
4844 | 1218 |
<resource: #obsolete> |
1219 |
||
72 | 1220 |
^ self at:aKey ifAbsent:default |
2 | 1221 |
! |
1222 |
||
8630 | 1223 |
resourcePackContainingKey:aKey |
1224 |
"returns the resolving resourcePack or nil." |
|
1225 |
||
1226 |
|val| |
|
1227 |
||
1228 |
aKey isNil ifTrue:[^ nil ]. |
|
1229 |
||
1230 |
val := self localAt:aKey. |
|
1231 |
val notNil ifTrue:[^ self]. |
|
1232 |
||
1233 |
self superPackHierarchyDo:[:eachPack | |
|
1234 |
val := eachPack localAt:aKey. |
|
1235 |
val notNil ifTrue:[ |
|
1236 |
^ eachPack. |
|
1237 |
]. |
|
1238 |
]. |
|
1239 |
^ nil. |
|
1240 |
||
1241 |
" |
|
1242 |
Workspace classResources resourcePackContainingKey:'Cancel' |
|
1243 |
WorkspaceApplication classResources resourcePackContainingKey:'Cancel' |
|
1244 |
" |
|
1245 |
||
1246 |
"Created: / 20-02-2019 / 12:46:32 / Claus Gittinger" |
|
1247 |
! |
|
1248 |
||
0 | 1249 |
string:s |
3097 | 1250 |
"translate (retrieve) a string - if not present, return s" |
123 | 1251 |
|
72 | 1252 |
^ self at:s ifAbsent:s |
3097 | 1253 |
|
1254 |
" |
|
1255 |
NewLauncher classResources |
|
8462 | 1256 |
string:'LICENCEFILE' |
3097 | 1257 |
" |
0 | 1258 |
! |
1259 |
||
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1260 |
string:s default:defaultString |
3097 | 1261 |
"translate (retrieve) a string - if not present, return defaultString" |
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1262 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1263 |
^ self at:s ifAbsent:defaultString |
3097 | 1264 |
|
1265 |
" |
|
1266 |
NewLauncher classResources |
|
8462 | 1267 |
string:'fooBar' default:'Hello world' |
3097 | 1268 |
" |
1269 |
||
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1270 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1271 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1272 |
string:s default:defaultString with:arg |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1273 |
"translate and expand arg" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1274 |
|
8445 | 1275 |
^ self string:s default:defaultString withArguments:(Array with:arg) |
3097 | 1276 |
|
1277 |
" |
|
1278 |
NewLauncher classResources |
|
8445 | 1279 |
string:'%1 fooBar' default:'Hello %1' with:'foo' |
3097 | 1280 |
" |
1281 |
||
8445 | 1282 |
"Modified: / 09-08-2018 / 14:55:56 / Claus Gittinger" |
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1283 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1284 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1285 |
string:s default:defaultString with:arg1 with:arg2 |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1286 |
"translate and expand args" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1287 |
|
8445 | 1288 |
^ self string:s default:defaultString withArguments:(Array with:arg1 with:arg2) |
1289 |
||
1290 |
"Modified: / 09-08-2018 / 14:55:53 / Claus Gittinger" |
|
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1291 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1292 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1293 |
string:s default:defaultString with:arg1 with:arg2 with:arg3 |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1294 |
"translate and expand args" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1295 |
|
8445 | 1296 |
^ self string:s default:defaultString withArguments:(Array with:arg1 with:arg2 with:arg3) |
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1297 |
|
8445 | 1298 |
"Created: / 09-12-1995 / 19:08:50 / cg" |
1299 |
"Modified: / 09-08-2018 / 14:55:51 / Claus Gittinger" |
|
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1300 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1301 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1302 |
string:s default:defaultString with:arg1 with:arg2 with:arg3 with:arg4 |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1303 |
"translate and expand args" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1304 |
|
8445 | 1305 |
^ self string:s default:defaultString withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1306 |
|
8445 | 1307 |
"Created: / 09-09-1996 / 18:52:14 / cg" |
1308 |
"Modified: / 09-08-2018 / 14:55:47 / Claus Gittinger" |
|
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1309 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1310 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1311 |
string:s default:defaultString withArgs:argArray |
8445 | 1312 |
<resource: #obsolete> |
1313 |
"translate and expand args" |
|
1314 |
||
1315 |
^ self string:s default:defaultString withArguments:argArray |
|
1316 |
||
1317 |
"Modified: / 09-08-2018 / 14:55:38 / Claus Gittinger" |
|
1318 |
! |
|
1319 |
||
1320 |
string:s default:defaultString withArguments:argArray |
|
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1321 |
"translate and expand args" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1322 |
|
5070 | 1323 |
|template| |
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1324 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1325 |
template := self at:s ifAbsent:defaultString. |
5070 | 1326 |
^ template expandPlaceholdersWith:argArray. |
8445 | 1327 |
|
1328 |
"Created: / 09-08-2018 / 14:55:29 / Claus Gittinger" |
|
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1329 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1330 |
|
0 | 1331 |
string:s with:arg |
123 | 1332 |
"translate and expand arg" |
1333 |
||
8445 | 1334 |
^ self string:s withArguments:(Array with:arg) |
1335 |
||
1336 |
"Modified: / 09-08-2018 / 14:56:02 / Claus Gittinger" |
|
0 | 1337 |
! |
1338 |
||
1339 |
string:s with:arg1 with:arg2 |
|
123 | 1340 |
"translate and expand args" |
1341 |
||
8445 | 1342 |
^ self string:s withArguments:(Array with:arg1 with:arg2) |
1343 |
||
1344 |
"Modified: / 09-08-2018 / 14:56:04 / Claus Gittinger" |
|
0 | 1345 |
! |
1346 |
||
292
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1347 |
string:s with:arg1 with:arg2 with:arg3 |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1348 |
"translate and expand args" |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1349 |
|
8445 | 1350 |
^ self string:s withArguments:(Array with:arg1 with:arg2 with:arg3) |
292
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1351 |
|
8445 | 1352 |
"Created: / 09-12-1995 / 19:08:50 / cg" |
1353 |
"Modified: / 09-08-2018 / 14:56:06 / Claus Gittinger" |
|
292
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1354 |
! |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1355 |
|
1042 | 1356 |
string:s with:arg1 with:arg2 with:arg3 with:arg4 |
1357 |
"translate and expand args" |
|
1358 |
||
8445 | 1359 |
^ self string:s withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
1042 | 1360 |
|
8445 | 1361 |
"Created: / 09-09-1996 / 18:52:14 / cg" |
1362 |
"Modified: / 09-08-2018 / 14:56:09 / Claus Gittinger" |
|
1042 | 1363 |
! |
1364 |
||
3184 | 1365 |
string:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
1366 |
"translate and expand args" |
|
1367 |
||
8445 | 1368 |
^ self string:s withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
3184 | 1369 |
|
8445 | 1370 |
"Modified: / 09-08-2018 / 14:56:12 / Claus Gittinger" |
3184 | 1371 |
! |
1372 |
||
5652 | 1373 |
string:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 |
1374 |
"translate and expand args" |
|
1375 |
||
8445 | 1376 |
^ self string:s withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6) |
5652 | 1377 |
|
1378 |
"Created: / 13-11-2010 / 11:35:00 / cg" |
|
8445 | 1379 |
"Modified: / 09-08-2018 / 14:56:14 / Claus Gittinger" |
5652 | 1380 |
! |
1381 |
||
1382 |
string:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 |
|
1383 |
"translate and expand args" |
|
1384 |
||
8445 | 1385 |
^ self string:s withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7) |
5652 | 1386 |
|
1387 |
"Created: / 13-11-2010 / 11:35:07 / cg" |
|
8445 | 1388 |
"Modified: / 09-08-2018 / 14:55:07 / Claus Gittinger" |
5652 | 1389 |
! |
1390 |
||
0 | 1391 |
string:s withArgs:argArray |
8445 | 1392 |
<resource: #obsolete> |
1393 |
"translate and expand args - allow text as arguments" |
|
1394 |
||
1395 |
^ self string:s withArguments:argArray |
|
1396 |
||
1397 |
"Modified: / 09-08-2018 / 14:54:54 / Claus Gittinger" |
|
1398 |
! |
|
1399 |
||
1400 |
string:s withArguments:argArray |
|
4932
b19b928b0026
Allow (and insert) Texts as arguments in #string:with:
Stefan Vogel <sv@exept.de>
parents:
4848
diff
changeset
|
1401 |
"translate and expand args - allow text as arguments" |
123 | 1402 |
|
5069 | 1403 |
|template| |
0 | 1404 |
|
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1405 |
template := self at:s ifAbsent:s. |
5069 | 1406 |
^ template expandPlaceholdersWith:argArray. |
4932
b19b928b0026
Allow (and insert) Texts as arguments in #string:with:
Stefan Vogel <sv@exept.de>
parents:
4848
diff
changeset
|
1407 |
|
8445 | 1408 |
"Created: / 09-08-2018 / 14:54:43 / Claus Gittinger" |
3823 | 1409 |
! |
1410 |
||
4402 | 1411 |
stringWithCRs:s |
8459 | 1412 |
"translate (retrieve) a string - if not present, return s. |
1413 |
replaces \'s with CRs" |
|
4402 | 1414 |
|
8459 | 1415 |
(s startsWith:':c:') ifTrue:[ |
1416 |
^ (self string:(s withoutPrefix:':c:')) withoutCEscapes |
|
1417 |
]. |
|
1418 |
(s startsWith:':st:') ifTrue:[ |
|
1419 |
^ (self string:(s withoutPrefix:':st:')) expandPlaceholdersWith:nil |
|
1420 |
]. |
|
4402 | 1421 |
^ (self string:s) withCRs |
1422 |
||
1423 |
" |
|
1424 |
NewLauncher classResources |
|
8459 | 1425 |
stringWithCRs:'LICENCEFILE' |
4402 | 1426 |
" |
8459 | 1427 |
|
1428 |
"Modified: / 07-09-2018 / 12:43:00 / Claus Gittinger" |
|
4402 | 1429 |
! |
1430 |
||
3823 | 1431 |
stringWithCRs:s with:arg |
1432 |
"translate, replace \'s with CRs and finally expand arg. |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1433 |
CR-replacement is donw before args are inserted |
3823 | 1434 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1435 |
||
8445 | 1436 |
^ self stringWithCRs:s withArguments:(Array with:arg) |
3823 | 1437 |
|
8445 | 1438 |
"Modified: / 21-03-2003 / 14:22:09 / cg" |
1439 |
"Modified: / 09-08-2018 / 14:56:21 / Claus Gittinger" |
|
3823 | 1440 |
! |
1441 |
||
1442 |
stringWithCRs:s with:arg1 with:arg2 |
|
1443 |
"translate, replace \'s with CRs and finally expand args. |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1444 |
CR-replacement is donw before args are inserted |
3823 | 1445 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1446 |
||
8445 | 1447 |
^ self stringWithCRs:s withArguments:(Array with:arg1 with:arg2) |
3823 | 1448 |
|
8445 | 1449 |
"Modified: / 21-03-2003 / 14:22:06 / cg" |
1450 |
"Modified: / 09-08-2018 / 14:56:25 / Claus Gittinger" |
|
3823 | 1451 |
! |
1452 |
||
1453 |
stringWithCRs:s with:arg1 with:arg2 with:arg3 |
|
1454 |
"translate, replace \'s with CRs and finally expand args. |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1455 |
CR-replacement is donw before args are inserted |
3823 | 1456 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1457 |
||
8445 | 1458 |
^ self stringWithCRs:s withArguments:(Array with:arg1 with:arg2 with:arg3) |
3823 | 1459 |
|
8445 | 1460 |
"Created: / 09-12-1995 / 19:08:50 / cg" |
1461 |
"Modified: / 09-08-2018 / 14:56:27 / Claus Gittinger" |
|
3823 | 1462 |
! |
1463 |
||
1464 |
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4 |
|
1465 |
"translate, replace \'s with CRs and finally expand args. |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1466 |
CR-replacement is donw before args are inserted |
3823 | 1467 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1468 |
||
8445 | 1469 |
^ self stringWithCRs:s withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
3823 | 1470 |
|
8445 | 1471 |
"Modified: / 21-03-2003 / 14:21:48 / cg" |
1472 |
"Modified: / 09-08-2018 / 14:56:30 / Claus Gittinger" |
|
3823 | 1473 |
! |
1474 |
||
1475 |
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
|
1476 |
"translate, replace \'s with CRs and finally expand args. |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1477 |
CR-replacement is donw before args are inserted |
3823 | 1478 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1479 |
||
8445 | 1480 |
^ self stringWithCRs:s withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
3823 | 1481 |
|
8445 | 1482 |
"Modified: / 21-03-2003 / 14:21:55 / cg" |
1483 |
"Modified: / 09-08-2018 / 14:56:32 / Claus Gittinger" |
|
3823 | 1484 |
! |
1485 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1486 |
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 |
5652 | 1487 |
"translate, replace \'s with CRs and finally expand args. |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1488 |
CR-replacement is donw before args are inserted |
5652 | 1489 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1490 |
||
8445 | 1491 |
^ self stringWithCRs:s withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6) |
5652 | 1492 |
|
1493 |
"Created: / 13-11-2010 / 11:35:30 / cg" |
|
8445 | 1494 |
"Modified: / 09-08-2018 / 14:56:35 / Claus Gittinger" |
5652 | 1495 |
! |
1496 |
||
1497 |
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 |
|
1498 |
"translate, replace \'s with CRs and finally expand args. |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1499 |
CR-replacement is donw before args are inserted |
5652 | 1500 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1501 |
||
8445 | 1502 |
^ self stringWithCRs:s withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7) |
5652 | 1503 |
|
1504 |
"Created: / 13-11-2010 / 11:35:20 / cg" |
|
8445 | 1505 |
"Modified: / 09-08-2018 / 14:56:37 / Claus Gittinger" |
5652 | 1506 |
! |
1507 |
||
3823 | 1508 |
stringWithCRs:s withArgs:argArray |
8445 | 1509 |
<resource: #obsolete> |
1510 |
"translate, replace \'s with CRs and finally expand args. |
|
1511 |
CR-replacement is done before args are inserted |
|
1512 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
|
1513 |
||
1514 |
^ self stringWithCRs:s withArguments:argArray |
|
1515 |
||
1516 |
"Modified: / 09-08-2018 / 14:54:29 / Claus Gittinger" |
|
1517 |
! |
|
1518 |
||
1519 |
stringWithCRs:s withArguments:argArray |
|
3823 | 1520 |
"translate, replace \'s with CRs and finally expand args. |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1521 |
CR-replacement is done before args are inserted |
3823 | 1522 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1523 |
||
5070 | 1524 |
|template| |
3823 | 1525 |
|
1526 |
template := self at:s ifAbsent:s. |
|
8459 | 1527 |
(s startsWith:':c:') ifTrue:[ |
1528 |
^ (self string:(s withoutPrefix:':c:')) withoutCEscapes expandPlaceholdersWith:argArray |
|
1529 |
]. |
|
1530 |
(s startsWith:':st:') ifTrue:[ |
|
1531 |
^ (self string:(s withoutPrefix:':st:')) expandPlaceholdersWith:argArray |
|
1532 |
]. |
|
5070 | 1533 |
^ template withCRs expandPlaceholdersWith:argArray. |
8445 | 1534 |
|
1535 |
"Created: / 09-08-2018 / 14:54:16 / Claus Gittinger" |
|
8459 | 1536 |
"Modified: / 07-09-2018 / 12:44:06 / Claus Gittinger" |
6174 | 1537 |
! |
1538 |
||
8630 | 1539 |
superPackHierarchyDo:aBlock |
1540 |
"evaluate aBlock for all of the searched super packs; |
|
1541 |
that is my project's pack and my superpack(s)" |
|
1542 |
||
1543 |
|pack alreadySearched toSearch more| |
|
1544 |
||
1545 |
superPacks notEmptyOrNil ifTrue:[ |
|
1546 |
alreadySearched := Set new. |
|
1547 |
toSearch := OrderedCollection withAll:superPacks. |
|
1548 |
[toSearch notEmpty] whileTrue:[ |
|
1549 |
pack := toSearch removeFirst. |
|
1550 |
(alreadySearched includes:pack packsFileName) ifFalse:[ |
|
1551 |
aBlock value:pack. |
|
1552 |
||
1553 |
alreadySearched add:pack packsFileName. |
|
1554 |
(more := pack superPacks) notEmptyOrNil ifTrue:[ |
|
1555 |
self assert:(more conform:[:each | each isNil or:[pack isKindOf:ResourcePack]]). |
|
1556 |
toSearch addAll:more. |
|
1557 |
]. |
|
1558 |
]. |
|
1559 |
]. |
|
1560 |
]. |
|
1561 |
||
1562 |
"Created: / 20-02-2019 / 12:49:56 / Claus Gittinger" |
|
1563 |
! |
|
1564 |
||
6174 | 1565 |
whichPackIncludesKey:aKey |
1566 |
"for debugging: return the pack (alogn the super-pack chain), which |
|
1567 |
has a translation for a string" |
|
1568 |
||
8510 | 1569 |
|val pack projectPack alreadySearched toSearch| |
6174 | 1570 |
|
1571 |
aKey isNil ifTrue:[ ^ nil ]. |
|
1572 |
||
1573 |
val := self localAt:aKey. |
|
1574 |
val notNil ifTrue:[^ self]. |
|
1575 |
||
8516 | 1576 |
superPacks isEmptyOrNil ifTrue:[^ nil]. |
6174 | 1577 |
|
8510 | 1578 |
alreadySearched := Set new. |
1579 |
toSearch := OrderedCollection withAll:superPacks. |
|
1580 |
[toSearch notEmpty] whileTrue:[ |
|
1581 |
pack := toSearch removeFirst. |
|
1582 |
(alreadySearched includes:pack) ifFalse:[ |
|
1583 |
val := pack localAt:aKey. |
|
1584 |
val notNil ifTrue:[^ pack]. |
|
1585 |
alreadySearched add:pack. |
|
1586 |
toSearch addAll:(pack superPacks). |
|
8462 | 1587 |
]. |
6174 | 1588 |
]. |
8510 | 1589 |
^ nil. |
1590 |
||
1591 |
"/ (projectPack := self projectPack) notNil ifTrue:[ |
|
1592 |
"/ val := projectPack localAt:aKey. |
|
1593 |
"/ val notNil ifTrue:[^ projectPack]. |
|
1594 |
"/ ]. |
|
1595 |
"/ alreadySearched := Set new. |
|
1596 |
"/ projectPack notNil ifTrue:[ alreadySearched add:projectPack ]. |
|
1597 |
"/ |
|
1598 |
"/ pack := self superPack. |
|
1599 |
"/ [ pack notNil ] whileTrue:[ |
|
1600 |
"/ val := pack localAt:aKey. |
|
1601 |
"/ val notNil ifTrue:[^ pack]. |
|
1602 |
"/ |
|
1603 |
"/ (projectPack := pack projectPack) notNil ifTrue:[ |
|
1604 |
"/ (alreadySearched includes:projectPack) ifFalse:[ |
|
1605 |
"/ val := projectPack localAt:aKey. |
|
1606 |
"/ val notNil ifTrue:[^ projectPack]. |
|
1607 |
"/ alreadySearched add:projectPack. |
|
1608 |
"/ ]. |
|
1609 |
"/ ]. |
|
1610 |
"/ pack := pack superPack |
|
1611 |
"/ ]. |
|
1612 |
"/ |
|
1613 |
"/ alreadySearched copy do:[:projectPack | |
|
1614 |
"/ |p| |
|
1615 |
"/ |
|
1616 |
"/ p := projectPack superPack. |
|
1617 |
"/ [p notNil and:[(alreadySearched includes:p) not]] whileTrue:[ |
|
1618 |
"/ val := p localAt:aKey. |
|
1619 |
"/ val notNil ifTrue:[^ p]. |
|
1620 |
"/ alreadySearched add:p. |
|
1621 |
"/ p := p superPack. |
|
1622 |
"/ ]. |
|
1623 |
"/ ]. |
|
1624 |
"/ |
|
1625 |
"/ ^ nil |
|
0 | 1626 |
! ! |
1627 |
||
3317 | 1628 |
!ResourcePack methodsFor:'accessing-internals'! |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1629 |
|
8510 | 1630 |
addSuperPack:anotherResourcePack |
1631 |
(anotherResourcePack == self) ifTrue:[ |
|
1632 |
^ self |
|
1633 |
]. |
|
1634 |
superPacks isNil ifTrue:[ superPacks := OrderedCollection new ]. |
|
1635 |
(superPacks includes:anotherResourcePack) ifFalse:[ |
|
1636 |
self assert:(anotherResourcePack isKindOf:ResourcePack). |
|
1637 |
superPacks add:anotherResourcePack |
|
1638 |
]. |
|
1639 |
! |
|
1640 |
||
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1641 |
name:aKey |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1642 |
"translate a string" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1643 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1644 |
^ self at:aKey ifAbsent:aKey |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1645 |
! |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1646 |
|
8517 | 1647 |
packsFileName |
1648 |
^ packsFileName |
|
1649 |
! |
|
1650 |
||
1651 |
packsPackage |
|
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1652 |
^ packsClassName |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1653 |
! |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1654 |
|
8517 | 1655 |
packsPackage:aPackage |
1656 |
packsClassName := aPackage |
|
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1657 |
! |
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1658 |
|
4617 | 1659 |
projectPack |
1660 |
^ projectPack |
|
1661 |
||
1662 |
"Created: / 18-09-2006 / 17:38:07 / cg" |
|
1663 |
! |
|
1664 |
||
8510 | 1665 |
superPacks |
1666 |
^ superPacks ? #() |
|
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1667 |
! ! |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1668 |
|
0 | 1669 |
!ResourcePack methodsFor:'file reading'! |
1670 |
||
684 | 1671 |
fileReadFailed |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1672 |
"return true, if the pack does not really contain |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1673 |
valid translations, since the fileRead failed. |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1674 |
However, all inherited translations are still available |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1675 |
through the receiver" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1676 |
|
687 | 1677 |
^ fileReadFailed ~~ false |
684 | 1678 |
|
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1679 |
"Created: / 14.5.1996 / 10:19:26 / cg" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1680 |
"Modified: / 29.1.1998 / 22:46:38 / cg" |
684 | 1681 |
! |
1682 |
||
1894
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1683 |
nonexistingFileRead |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1684 |
"asked to read definitions for a non-existing file. |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1685 |
Here, this is legal and ignored (typically using inherited resources). |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1686 |
However, subclasses (such as styleSheet) may flag it as an error." |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1687 |
|
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1688 |
^ nil |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1689 |
|
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1690 |
"Created: 6.9.1997 / 11:38:53 / cg" |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1691 |
! |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1692 |
|
4332 | 1693 |
processLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError |
145 | 1694 |
"process a single valid line (i.e. #ifdef & #include has already been processed)" |
1695 |
||
4509 | 1696 |
self class |
8462 | 1697 |
processResourceLine:lineString |
1698 |
encoding:encodingSymbolOrEncoder |
|
1699 |
file:fileName |
|
1700 |
printErrorWith:printError |
|
1701 |
for:self |
|
144 | 1702 |
! |
1703 |
||
244 | 1704 |
readFromFile:fileName directory:dirName |
1705 |
"read definitions from a file in a directory" |
|
1706 |
||
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1707 |
|triedFilename inStream ok| |
244 | 1708 |
|
686 | 1709 |
fileReadFailed := false. |
5781
fc35ed4fd223
changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents:
5653
diff
changeset
|
1710 |
"/ need to catch errors here, as the handler might itself need resources. |
fc35ed4fd223
changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents:
5653
diff
changeset
|
1711 |
"/ (happens when da.rs is not present in libbasic/resources.rs) |
fc35ed4fd223
changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents:
5653
diff
changeset
|
1712 |
ExternalStream openErrorSignal handle:[:ex | |
8462 | 1713 |
Transcript showCR:'ResourcePack: failed to open file: ',fileName asString,' in ',dirName asString. |
1714 |
inStream := nil. |
|
5781
fc35ed4fd223
changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents:
5653
diff
changeset
|
1715 |
] do:[ |
8462 | 1716 |
dirName = 'resources' ifTrue:[ |
1717 |
inStream := Smalltalk resourceFileStreamFor:fileName |
|
1718 |
] ifFalse:[ |
|
1719 |
inStream := Smalltalk systemFileStreamFor: |
|
1720 |
(dirName isNil |
|
1721 |
ifTrue:[fileName] |
|
1722 |
ifFalse:[dirName asFilename construct:fileName]). |
|
1723 |
]. |
|
244 | 1724 |
]. |
5781
fc35ed4fd223
changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents:
5653
diff
changeset
|
1725 |
|
8515 | 1726 |
"/ '7) inStream ' print. inStream printCR. |
8512 | 1727 |
|
244 | 1728 |
inStream isNil ifTrue:[ |
8462 | 1729 |
" |
1730 |
an empty pack |
|
1731 |
" |
|
1732 |
^ self nonexistingFileRead |
|
244 | 1733 |
]. |
2996 | 1734 |
|
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1735 |
triedFilename := inStream pathName. |
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1736 |
[ |
8462 | 1737 |
ok := self readFromResourceStream:inStream in:(triedFilename asFilename directoryName). |
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1738 |
] ensure:[ |
8462 | 1739 |
inStream close. |
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1740 |
]. |
686 | 1741 |
|
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1742 |
ok ifTrue:[ |
8462 | 1743 |
packsFileName := triedFilename |
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1744 |
] ifFalse:[ |
8462 | 1745 |
fileReadFailed := true. |
684 | 1746 |
|
8667 | 1747 |
Logger warning:'ResourcePack [warning]: "%1" contains error(s) - data may be incomplete.' |
1748 |
with:triedFilename. |
|
244 | 1749 |
]. |
1750 |
||
5781
fc35ed4fd223
changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents:
5653
diff
changeset
|
1751 |
"Modified: / 20-08-2011 / 17:10:02 / cg" |
8667 | 1752 |
"Modified: / 27-03-2019 / 11:01:57 / Claus Gittinger" |
244 | 1753 |
! |
1754 |
||
72 | 1755 |
readFromResourceStream:inStream in:dirName |
4848 | 1756 |
"read definitions from a stream. The dirName argument is required to |
210
0f942dafc85a
gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents:
177
diff
changeset
|
1757 |
specify where #include files are searched for. |
0f942dafc85a
gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents:
177
diff
changeset
|
1758 |
Return true, if the style sheet could be read without errors, false otherwise." |
145 | 1759 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1760 |
|lineString l lineNumber rest value ifLevel skipping first ok encoding decoder pack errorHandler |
4947 | 1761 |
printError fileName pushedSkipValues| |
4058 | 1762 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1763 |
fileName := (inStream isFileStream |
8636 | 1764 |
ifTrue:[inStream baseName] |
6992 | 1765 |
ifFalse:['---']). |
4058 | 1766 |
|
8667 | 1767 |
DebugResources == true ifTrue:[ |
1768 |
printError := [:message | |
|
1769 |
Logger warning:'ResourcePack [warning]: %1 in file: %2 line: %3' |
|
1770 |
with:message |
|
1771 |
with:fileName |
|
1772 |
with:lineNumber. |
|
1773 |
]. |
|
1774 |
] ifFalse:[ |
|
1775 |
printError := [:message | ]. |
|
1776 |
]. |
|
1777 |
||
462
423f8426fefc
added #encoding directive (I am lazy)
Claus Gittinger <cg@exept.de>
parents:
444
diff
changeset
|
1778 |
encoding := nil. |
0 | 1779 |
|
210
0f942dafc85a
gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents:
177
diff
changeset
|
1780 |
ok := true. |
0 | 1781 |
ifLevel := 0. |
1782 |
skipping := false. |
|
4058 | 1783 |
lineNumber := 0. |
4947 | 1784 |
pushedSkipValues := OrderedCollection new. |
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
1785 |
|
8667 | 1786 |
errorHandler := |
1787 |
[:ex | |
|
1788 |
|con count| |
|
4947 | 1789 |
|
8667 | 1790 |
Logger warning:'ResourcePack [warning]: "%1"' with:ex description. |
1791 |
Logger warning:'ResourcePack [info]: in: %1 [%2]: "%3"' |
|
1792 |
with:inStream pathName |
|
1793 |
with:lineNumber |
|
1794 |
with:lineString. |
|
1795 |
con := ex suspendedContext. |
|
1796 |
Logger warning:'ResourcePack [info]: in: %1' with:con fullPrintString. |
|
1797 |
con := con sender. |
|
1798 |
count := 1. |
|
1799 |
[con notNil and:[count <= 20]] whileTrue:[ |
|
1800 |
Logger warning:'ResourcePack [info]: : %1' with:con fullPrintString. |
|
1801 |
count := count + 1. |
|
1802 |
con := con sender. |
|
1803 |
]. |
|
1804 |
value := nil. |
|
1805 |
ok := false. |
|
1806 |
]. |
|
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
1807 |
|
0 | 1808 |
[inStream atEnd] whileFalse:[ |
6992 | 1809 |
lineString := inStream nextLine. lineNumber := lineNumber + 1. |
1810 |
[lineString notNil and:[lineString endsWith:$\]] whileTrue:[ |
|
1811 |
lineString := lineString copyButLast:1. |
|
1812 |
l := inStream nextLine. lineNumber := lineNumber + 1. |
|
1813 |
l notNil ifTrue:[ |
|
1814 |
lineString := lineString , l. |
|
1815 |
]. |
|
1816 |
]. |
|
177 | 1817 |
|
8650 | 1818 |
(lineString size ~~ 0) ifTrue:[ |
6992 | 1819 |
first := lineString at:1. |
1820 |
"/ |
|
1821 |
"/ for your convenience: treat both ';' AND '"/' as comment-line |
|
1822 |
"/ |
|
1823 |
((first == $;) or:[lineString startsWith:'"/']) ifFalse:[ |
|
1824 |
((first == $#) and:[(lineString startsWith:'#(') not]) ifTrue:[ |
|
1825 |
"/ a directive |
|
1826 |
lineString := (lineString copyFrom:2) withoutSpaces. |
|
72 | 1827 |
|
6992 | 1828 |
(lineString startsWith:'if') ifTrue:[ |
1829 |
pushedSkipValues add:skipping. |
|
1830 |
skipping ifFalse:[ |
|
1831 |
rest := lineString copyFrom:3. |
|
1832 |
Error, UserInformation |
|
1833 |
handle:errorHandler |
|
1834 |
do:[ |
|
1835 |
value := Compiler evaluate:rest compile:false. |
|
1836 |
]. |
|
1837 |
(value == #Error) ifTrue:[ |
|
1838 |
printError value:('error in resource:' , lineString). |
|
1839 |
]. |
|
1840 |
(value == false) ifTrue:[ |
|
1841 |
skipping := true |
|
1842 |
] |
|
1843 |
]. |
|
1844 |
ifLevel := ifLevel + 1 |
|
1845 |
] ifFalse:[ |
|
1846 |
(lineString startsWith:'endif') ifTrue:[ |
|
1847 |
ifLevel == 0 ifTrue:[ |
|
1848 |
printError value:('if/endif nesting error'). |
|
1849 |
] ifFalse:[ |
|
1850 |
ifLevel := ifLevel - 1. |
|
1851 |
skipping := pushedSkipValues removeLast. |
|
1852 |
] |
|
1853 |
] ifFalse:[ |
|
1854 |
(lineString startsWith:'else') ifTrue:[ |
|
1855 |
(pushedSkipValues includes:true) ifFalse:[ |
|
1856 |
skipping := skipping not |
|
1857 |
] |
|
1858 |
] ifFalse:[ |
|
1859 |
skipping ifFalse:[ |
|
1860 |
(lineString startsWith:'superpack') ifTrue:[ |
|
1861 |
rest := lineString copyFrom:('superpack' size + 1). |
|
1862 |
value := Compiler evaluate:rest compile:false. |
|
1863 |
(value isKindOf:ResourcePack) ifTrue:[ |
|
8517 | 1864 |
self addSuperPack:value. |
6992 | 1865 |
] |
1866 |
] ifFalse:[ |
|
1867 |
(lineString startsWith:'include') ifTrue:[ |
|
1868 |
(lineString startsWith:'includeResourcesFor') ifTrue:[ |
|
1869 |
"/ include those resources ... |
|
1870 |
rest := lineString copyFrom:('includeResourcesFor' size + 1). |
|
1871 |
value := Compiler evaluate:rest compile:false. |
|
1872 |
value isBehavior ifTrue:[ |
|
1873 |
pack := self class for:value. |
|
1874 |
pack notNil ifTrue:[ |
|
1875 |
self addAll:pack. |
|
1876 |
] |
|
1877 |
] |
|
1878 |
] ifFalse:[ |
|
1879 |
rest := lineString copyFrom:('include' size + 1). |
|
1880 |
value := Compiler evaluate:rest compile:false. |
|
1881 |
value isString ifFalse:[ |
|
1882 |
printError value:('bad include filename: ' , value printString, ' "',lineString,'"'). |
|
1883 |
] ifTrue:[ |
|
1884 |
self readFromFile:value directory:dirName |
|
1885 |
] |
|
1886 |
] |
|
1887 |
] ifFalse:[ |
|
1888 |
(lineString startsWith:'encoding') ifTrue:[ |
|
4848 | 1889 |
"/decoder notNil ifTrue:[self halt:'oops - encoding change in file']. |
6992 | 1890 |
encoding := self class extractEncodingFromLine:lineString. |
1891 |
decoder := CharacterEncoder encoderFor:encoding ifAbsent:nil. |
|
1892 |
] |
|
1893 |
] |
|
1894 |
] |
|
1895 |
] |
|
1896 |
] |
|
1897 |
] |
|
1898 |
]. |
|
1899 |
] ifFalse:[ |
|
1900 |
skipping ifFalse:[ |
|
1901 |
Error, UserInformation |
|
1902 |
handle:errorHandler |
|
1903 |
do:[ |
|
1904 |
(lineString at:1) == $!! ifTrue:[ |
|
1905 |
"/ evaluate the rest |
|
1906 |
Compiler evaluate:(lineString copyFrom:2) |
|
1907 |
receiver:self |
|
1908 |
notifying:nil |
|
1909 |
compile:false. |
|
1910 |
] ifFalse:[ |
|
1911 |
"/ process as resource |
|
8667 | 1912 |
self class |
1913 |
processResourceLine:lineString |
|
6992 | 1914 |
encoding:decoder |
1915 |
file:(inStream isFileStream |
|
1916 |
ifTrue:[inStream pathName] |
|
1917 |
ifFalse:['---']) |
|
1918 |
printErrorWith:printError |
|
8667 | 1919 |
for:self |
6992 | 1920 |
]] |
1921 |
] |
|
1922 |
] |
|
1923 |
] |
|
1924 |
] |
|
0 | 1925 |
]. |
210
0f942dafc85a
gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents:
177
diff
changeset
|
1926 |
^ ok |
177 | 1927 |
|
4534
d71ca6ac7cbe
handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents:
4531
diff
changeset
|
1928 |
"Modified: / 31-08-1995 / 02:33:45 / claus" |
4619 | 1929 |
"Modified: / 18-09-2006 / 20:35:37 / cg" |
8496 | 1930 |
"Modified: / 10-10-2018 / 14:14:00 / sr" |
8637 | 1931 |
"Modified: / 22-02-2019 / 17:13:13 / Stefan Vogel" |
8667 | 1932 |
"Modified: / 27-03-2019 / 12:01:12 / Claus Gittinger" |
0 | 1933 |
! ! |
1934 |
||
8509 | 1935 |
|
4093 | 1936 |
!ResourcePack methodsFor:'printing & storing'! |
1937 |
||
5603
0945abfddb9a
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
5593
diff
changeset
|
1938 |
displayOn:aGCOrStream |
0945abfddb9a
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
5593
diff
changeset
|
1939 |
|
0945abfddb9a
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
5593
diff
changeset
|
1940 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
7931 | 1941 |
"/ old ST80 means: draw-yourself on a GC. |
1942 |
(aGCOrStream isStream) ifFalse:[ |
|
1943 |
^ super displayOn:aGCOrStream |
|
5603
0945abfddb9a
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
5593
diff
changeset
|
1944 |
]. |
0945abfddb9a
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
5593
diff
changeset
|
1945 |
|
8667 | 1946 |
aGCOrStream nextPutAll:self class name. |
1947 |
packsClassName notNil ifTrue:[ |
|
1948 |
aGCOrStream nextPutAll:' for: '. |
|
1949 |
packsClassName printOn:aGCOrStream. |
|
1950 |
] ifFalse:[ |
|
1951 |
aGCOrStream nextPutAll:' from: '. |
|
1952 |
packsFileName printOn:aGCOrStream. |
|
1953 |
]. |
|
7931 | 1954 |
|
1955 |
"Modified: / 22-02-2017 / 17:00:31 / cg" |
|
8667 | 1956 |
"Modified: / 27-03-2019 / 11:14:05 / Claus Gittinger" |
4093 | 1957 |
! ! |
1958 |
||
8461 | 1959 |
!ResourcePack methodsFor:'statistics'! |
1960 |
||
1961 |
forgetUsedKeys |
|
1962 |
"stop keeping a statistic on which keys are actually used" |
|
1963 |
||
1964 |
usedKeys := nil. |
|
1965 |
||
1966 |
"Modified (comment): / 12-09-2018 / 18:23:27 / Claus Gittinger" |
|
1967 |
! |
|
1968 |
||
1969 |
rememberUsedKeys |
|
1970 |
"start keeping a statistic on which keys are actually used" |
|
1971 |
||
1972 |
usedKeys := Set new. |
|
1973 |
||
1974 |
"Modified (comment): / 12-09-2018 / 18:23:22 / Claus Gittinger" |
|
1975 |
! |
|
1976 |
||
1977 |
usedKeys |
|
1978 |
"get keys which were actually used. |
|
1979 |
(must call #rememberUsedKeys before)" |
|
1980 |
||
1981 |
^ usedKeys |
|
1982 |
||
1983 |
"Created: / 12-09-2018 / 18:24:26 / Claus Gittinger" |
|
1984 |
! ! |
|
1985 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1986 |
!ResourcePack class methodsFor:'documentation'! |
251 | 1987 |
|
1988 |
version |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1989 |
^ '$Header$' |
5357 | 1990 |
! |
1991 |
||
1992 |
version_CVS |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1993 |
^ '$Header$' |
251 | 1994 |
! ! |
3769 | 1995 |
|
6051
f01078ce8c2c
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
5951
diff
changeset
|
1996 |
|
0 | 1997 |
ResourcePack initialize! |