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