author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 03 Oct 2017 11:38:15 +0100 | |
branch | jv |
changeset 8188 | 00df122d8bd4 |
parent 7963 | 76834c6940c7 |
child 8224 | 6d994e1ee4fc |
permissions | -rw-r--r-- |
5 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
72 | 3 |
All Rights Reserved |
5 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
3263 | 12 |
"{ Package: 'stx:libview' }" |
13 |
||
6767 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
Dictionary subclass:#ResourcePack |
7387 | 17 |
instanceVariableNames:'packsClassName packsFileName fileReadFailed superPack projectPack |
18 |
usedKeys' |
|
19 |
classVariableNames:'Packs FailedToLoadPacks DebugModifications |
|
20 |
KeepStatisticsOnUsedKeys' |
|
308
54fa63d274fa
also allow "/ for comment lines
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
21 |
poolDictionaries:'' |
3484 | 22 |
category:'Interface-Internationalization' |
0 | 23 |
! |
24 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
25 |
!ResourcePack class methodsFor:'documentation'! |
46 | 26 |
|
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
72 | 30 |
All Rights Reserved |
5 | 31 |
|
46 | 32 |
This software is furnished under a license and may be used |
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
5 | 40 |
|
46 | 41 |
documentation |
42 |
" |
|
1942 | 43 |
This class supports easy customization of smalltalk code (i.e. internationalization |
44 |
and viewStyle adaption). |
|
145 | 45 |
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
|
46 |
and ApplicationModel has an instance of ResourcePack (instVar called 'resources') |
1942 | 47 |
which is created when the first instance of the view/app is created, |
48 |
and cached in a class-instVar (so the file is only read once). |
|
54 | 49 |
|
50 | 50 |
The resourcePack consists of a mapping from strings to values, which are |
51 |
then used in labels, buttons, menus etc. |
|
52 |
The resourcePack initializes itself from a file found in 'resources/<className>.rs', |
|
53 |
where 'className' is built by the usual abbreviation mechanism (see abbrev-files). |
|
1942 | 54 |
|
50 | 55 |
Conditional mappings are possible, by including lines as: |
7649 | 56 |
#if <expression> |
57 |
#endif |
|
50 | 58 |
in the resourcefile. Example: |
59 |
file 'foo.rs': |
|
7649 | 60 |
#if Language == #de |
61 |
'abort' 'Abbruch' |
|
62 |
#endif |
|
63 |
#if Language == #fr |
|
64 |
'abort' 'canceller' |
|
65 |
#endif |
|
145 | 66 |
|
67 |
the corresponding resource-strings are accessed (from methods within the class) |
|
68 |
using: |
|
7649 | 69 |
resources string:'abort' |
145 | 70 |
|
54 | 71 |
returning the mapped string (i.e. 'Abbruch' if the global Language is set |
3422 | 72 |
to #de).. |
145 | 73 |
|
1942 | 74 |
If no corresponding entry is found in the resources, the key is returned; |
75 |
alternatively, use: |
|
7649 | 76 |
resources string:'foo' default:'bar' |
1942 | 77 |
which returns 'bar', if no resource definition for 'foo' is found. |
78 |
||
54 | 79 |
Translations can also include arguments, such as: |
7649 | 80 |
resources string:'really delete %1' with:fileName |
145 | 81 |
|
82 |
This scheme has the advantage, that you can write your programs using your |
|
83 |
native language strings. Later, when new languages are to be supported, |
|
84 |
simply create a resource file for the class and add translations for |
|
85 |
all those strings. (find the keys by looking at users of resource or senders |
|
1942 | 86 |
of 'string:*'). |
87 |
Notice, that the grammar of different languages may imply a reordering, |
|
7649 | 88 |
so the above string becomes the german 'wollen Sie %1 wirklich löschen'; |
1942 | 89 |
so using percent-placeholders is much better than simple concatenations of |
90 |
arguments to the question. |
|
145 | 91 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
92 |
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
|
93 |
or the like. Even by people without access to the source code (i.e. which only have the |
5653 | 94 |
applications binary). |
145 | 95 |
|
96 |
Also, unsupported languages' strings are simply left unchanged - if you |
|
97 |
write your application in (say) english, and only plan to use it in english, |
|
5653 | 98 |
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
|
99 |
Strings for unknown languages will come in english |
145 | 100 |
(which is better than nothing or empty button labels ;-) |
101 |
||
7649 | 102 |
Notice, that you can also translate english to english, by providing an en.rs file. |
5653 | 103 |
This is sometimes useful to fix typing errors or bad syntax in the english, |
104 |
as sometimes made by the programmer, without a need to recompile or to also adjust other |
|
105 |
language translations. |
|
106 |
||
107 |
Finally, this scheme is also compatible to a pure enum-key based translation mechanism, |
|
108 |
as typically used in the C-world. |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
109 |
Simple use keys as argument, and provide translations for all languages (incl. english). |
5653 | 110 |
For example: |
7649 | 111 |
Button label:(resources string:#BTN_FOO_LABEL) |
5653 | 112 |
|
113 |
||
145 | 114 |
Summary: |
7649 | 115 |
in subclasses of View and ApplicationModel, instead of writing: |
145 | 116 |
|
7649 | 117 |
... |
118 |
b := Button label:'press me' |
|
119 |
... |
|
145 | 120 |
|
7649 | 121 |
always write: |
612 | 122 |
|
7649 | 123 |
... |
124 |
b := Button label:(resources string:'press me') |
|
125 |
... |
|
145 | 126 |
|
7649 | 127 |
if your class is not a subclass of one of the above, AND you need |
128 |
resource translations, you won't inherit the resources variable |
|
129 |
(which is automatically initialized). |
|
130 |
In this case, you have to ask the ResourcePack class explicitely for |
|
131 |
a corresponding package: |
|
5483 | 132 |
|
7649 | 133 |
ResourcePack for:aClassName |
134 |
or (even better): |
|
135 |
ResourcePack forPackage:aPackageID |
|
145 | 136 |
|
7649 | 137 |
as an example, see how the Date class gets the national names of |
138 |
week & monthnames. |
|
145 | 139 |
|
5483 | 140 |
Debugging: |
7649 | 141 |
in the past, it happened that strings as returned by me were modified by someone else |
142 |
(replaceAll:with:) and then lead to invalid presentation in the future. |
|
143 |
To detect any bad guy which writes into one of my returned strings, set the DebugModifications |
|
144 |
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
|
145 |
|
612 | 146 |
[author:] |
7649 | 147 |
Claus Gittinger |
145 | 148 |
" |
149 |
! |
|
150 |
||
151 |
examples |
|
152 |
" |
|
153 |
normally, resources are found in files named after their classes sourcefile |
|
154 |
For example, the FileBrowsers resources are found in 'FBrowser.rs'. |
|
155 |
For the examples below, we process resources from a constant string; |
|
3762 | 156 |
this is NOT representative. |
157 |
[exBegin] |
|
158 |
|stream res| |
|
145 | 159 |
|
3762 | 160 |
stream := ReadStream on:' |
145 | 161 |
foo ''the translation for foo'' |
3422 | 162 |
#if Language == #de |
145 | 163 |
bar ''die deutsche uebersetzung von bar'' |
164 |
baz ''baz hat den Wert %1'' |
|
165 |
#endif |
|
3422 | 166 |
#if Language == #fr |
145 | 167 |
bar ''bar en francaise'' |
168 |
baz ''%1, c''''est baz'' |
|
169 |
#endif |
|
170 |
||
171 |
'. |
|
172 |
||
3762 | 173 |
res := ResourcePack new readFromResourceStream:stream in:nil. |
145 | 174 |
|
3762 | 175 |
Transcript showCR:'baz is translated to: ' , (res string:'baz' with:'1234'). |
176 |
Transcript showCR:'bar is translated to: ' , (res string:'bar'). |
|
177 |
Transcript showCR:'foo is translated to: ' , (res string:'foo'). |
|
178 |
Transcript showCR:'fooBar is translated to: ' , (res string:'fooBar'). |
|
179 |
[exEnd] |
|
145 | 180 |
set the Language to french: |
3762 | 181 |
[exBegin] |
182 |
Language := #fr |
|
183 |
[exEnd] |
|
145 | 184 |
and repeat the above. |
620 | 185 |
back to english: |
3762 | 186 |
[exBegin] |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
187 |
Language := #en |
3762 | 188 |
[exEnd] |
620 | 189 |
back to german: |
3762 | 190 |
[exBegin] |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
191 |
Language := #de |
3762 | 192 |
[exEnd] |
46 | 193 |
" |
194 |
! ! |
|
5 | 195 |
|
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
196 |
!ResourcePack class methodsFor:'initialization'! |
0 | 197 |
|
72 | 198 |
flushCachedResourcePacks |
24 | 199 |
"forget all cached resources - needed after a style change" |
200 |
||
201 |
Packs := nil. |
|
202 |
self initialize |
|
203 |
||
4093 | 204 |
" |
205 |
ResourcePack flushCachedResourcePacks |
|
206 |
" |
|
244 | 207 |
! |
208 |
||
209 |
initialize |
|
210 |
Packs isNil ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
211 |
Packs := WeakArray new:100. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
212 |
FailedToLoadPacks := Set new. |
244 | 213 |
]. |
214 |
||
4093 | 215 |
" |
216 |
ResourcePack initialize |
|
217 |
" |
|
4623 | 218 |
|
5826
c4ed474970c1
forPackage:resourceFileName:cached:
Claus Gittinger <cg@exept.de>
parents:
5781
diff
changeset
|
219 |
"Modified: / 28-09-2011 / 15:53:21 / cg" |
244 | 220 |
! ! |
221 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
222 |
!ResourcePack class methodsFor:'instance creation'! |
244 | 223 |
|
224 |
for:aClass |
|
225 |
"get the full resource definitions for aClass (i.e. with super packs). |
|
226 |
Also leave the resulting pack in the cache for faster access next time." |
|
227 |
||
4619 | 228 |
^ self for:aClass cached:false |
4030 | 229 |
|
230 |
" |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
231 |
ResourcePack for:TextView |
4030 | 232 |
ResourcePack for:CodeView |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
233 |
ResourcePack for:Workspace |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
234 |
ResourcePack for:View |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
235 |
ResourcePack for:ErrorLogger |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
236 |
ResourcePack for:NewLauncher |
6799 | 237 |
ResourcePack for:SmallSense::SettingsAppl |
4030 | 238 |
Workspace classResources |
239 |
" |
|
4619 | 240 |
|
241 |
"Modified: / 18-09-2006 / 19:02:57 / cg" |
|
4030 | 242 |
! |
243 |
||
244 |
for:aClass cached:cached |
|
245 |
"get the full resource definitions for aClass (i.e. with super packs). |
|
246 |
Also leave the resulting pack in the cache for faster access next time." |
|
247 |
||
3980
443283639aed
resourceDirectory asked from class
Claus Gittinger <cg@exept.de>
parents:
3979
diff
changeset
|
248 |
|nm pack rsrcDir baseName| |
244 | 249 |
|
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
250 |
nm := aClass resourcePackName. |
4030 | 251 |
cached ifTrue:[ |
6909 | 252 |
pack := self searchCacheFor:nm. |
253 |
pack notNil ifTrue:[^ pack]. |
|
4030 | 254 |
]. |
244 | 255 |
|
3049
d5f2b3f66e37
load resources from package directory, if present
Claus Gittinger <cg@exept.de>
parents:
3047
diff
changeset
|
256 |
baseName := (Smalltalk fileNameForClass:nm) , '.rs'. |
3980
443283639aed
resourceDirectory asked from class
Claus Gittinger <cg@exept.de>
parents:
3979
diff
changeset
|
257 |
rsrcDir := aClass resourceDirectory. |
2970
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
258 |
|
4148 | 259 |
"/ CHECK this |
260 |
"/ (rsrcDir notNil and:[rsrcDir suffix = 'rs']) ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
261 |
"/ baseName := (Smalltalk fileNameForClass: rsrcDir tail asFilename withoutSuffix pathName),'.rs'. |
4148 | 262 |
"/ rsrcDir := rsrcDir head asFilename. |
263 |
"/ ]. |
|
264 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
265 |
rsrcDir notNil ifTrue:[ |
6909 | 266 |
pack := self new. |
267 |
rsrcDir exists ifTrue:[ |
|
268 |
(rsrcDir construct:baseName) exists ifTrue:[ |
|
269 |
pack := self fromFile:baseName directory:(rsrcDir name) cached:cached. |
|
270 |
]. |
|
271 |
] |
|
2970
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
272 |
] ifFalse:[ |
6909 | 273 |
pack := self fromFile:baseName directory:'resources' cached:cached. |
2970
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
274 |
]. |
4619 | 275 |
aClass superclass notNil ifTrue:[ |
6919 | 276 |
pack superPack:(self for:(aClass superclass) cached:cached). |
244 | 277 |
]. |
4093 | 278 |
pack packsClassOrFileName:nm. |
4030 | 279 |
cached ifTrue:[ |
6909 | 280 |
self addToCache:pack. |
4030 | 281 |
]. |
6909 | 282 |
pack projectPack:(self forPackage:(aClass resourcePackage) cached:cached). |
244 | 283 |
^ pack |
284 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
285 |
" |
4656 | 286 |
ResourcePack forPackage:'bosch:dapasx' cached:true |
287 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
288 |
ResourcePack for:TextView |
244 | 289 |
ResourcePack for:CodeView |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
290 |
ResourcePack for:Workspace |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
291 |
ResourcePack for:View |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
292 |
ResourcePack for:ErrorLogger |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
293 |
ResourcePack for:NewLauncher |
244 | 294 |
Workspace classResources |
295 |
" |
|
4617 | 296 |
|
5642
494cea2296dc
comment/format in: #for:cached:
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
297 |
"Modified: / 01-11-2010 / 09:09:43 / cg" |
244 | 298 |
! |
299 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
300 |
forPackage:package |
4078 | 301 |
"get the full resource definitions given a package id (such as stx:libbasic'). |
302 |
Also leave the resulting pack in the cache for faster access next time." |
|
303 |
||
304 |
^ self forPackage:package cached:true |
|
305 |
||
306 |
" |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
307 |
ResourcePack forPackage:'stx:libbasic' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
308 |
ResourcePack forPackage:'stx:libtool' |
4078 | 309 |
" |
4618 | 310 |
|
311 |
"Modified: / 18-09-2006 / 18:45:31 / cg" |
|
4078 | 312 |
! |
313 |
||
314 |
forPackage:package cached:cached |
|
315 |
"get the full resource definitions given a package id (such as stx:libbasic'). |
|
316 |
Also optionally leave the resulting pack in the cache for faster access next time." |
|
317 |
||
4673 | 318 |
^ self forPackage:package resourceFileName:'resources.rs' cached:cached |
319 |
||
320 |
" |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
321 |
ResourcePack forPackage:'stx:libbasic' cached:false |
4673 | 322 |
" |
323 |
||
324 |
"Modified: / 19-10-2006 / 23:18:28 / cg" |
|
325 |
! |
|
326 |
||
327 |
forPackage:package resourceFileName:resourceFileName cached:cached |
|
328 |
"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
|
329 |
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
|
330 |
Remember failed packs, to avoid retrying reading the file again and again" |
4673 | 331 |
|
4428 | 332 |
|fullName pack rsrcDir file| |
4078 | 333 |
|
4673 | 334 |
fullName := package , '/resources/',resourceFileName. |
4078 | 335 |
|
336 |
cached ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
337 |
pack := self searchCacheFor:fullName. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
338 |
pack notNil ifTrue:[^ pack]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
339 |
(FailedToLoadPacks includes:fullName) ifTrue:[^ nil]. |
4078 | 340 |
]. |
341 |
||
342 |
rsrcDir := Smalltalk projectDirectoryForPackage:package. |
|
4428 | 343 |
rsrcDir isNil ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
344 |
file := Smalltalk getResourceFileName:resourceFileName forPackage:package. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
345 |
file isNil ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
346 |
FailedToLoadPacks add:fullName. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
347 |
^ nil |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
348 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
349 |
rsrcDir := file asFilename directory. |
4428 | 350 |
] ifFalse:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
351 |
rsrcDir := rsrcDir asFilename construct:'resources'. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
352 |
rsrcDir exists ifFalse:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
353 |
FailedToLoadPacks add:fullName. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
354 |
^ nil |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
355 |
]. |
4428 | 356 |
]. |
4078 | 357 |
|
4673 | 358 |
pack := self fromFile:resourceFileName directory:rsrcDir cached:cached. |
4093 | 359 |
pack packsClassOrFileName:fullName. |
4078 | 360 |
^ pack |
361 |
||
362 |
" |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
363 |
ResourcePack forPackage:'stx:libbasic' resourceFileName:'resources.rs' cached:false |
4078 | 364 |
" |
4656 | 365 |
|
5826
c4ed474970c1
forPackage:resourceFileName:cached:
Claus Gittinger <cg@exept.de>
parents:
5781
diff
changeset
|
366 |
"Modified: / 28-09-2011 / 15:55:30 / cg" |
4078 | 367 |
! |
368 |
||
244 | 369 |
fromFile:aFileName |
4611 | 370 |
"get the resource definitions from a file in the default directory." |
244 | 371 |
|
372 |
^ self fromFile:aFileName directory:'resources' |
|
373 |
||
374 |
" |
|
375 |
ResourcePack fromFile:'SBrowser.rs' |
|
376 |
ResourcePack fromFile:'FBrowser.rs' |
|
377 |
ResourcePack fromFile:'Smalltalk.rs' |
|
3678 | 378 |
ResourcePack fromFile:'Smalltalk.rs' asFilename |
3983 | 379 |
ResourcePack fromFile:'../../libtool/resources/AboutBox_ru.rs' asFilename |
244 | 380 |
" |
381 |
! |
|
382 |
||
383 |
fromFile:aFileName directory:dirName |
|
4611 | 384 |
"get the resource definitions from a file in a directory." |
385 |
||
386 |
^ self fromFile:aFileName directory:dirName cached:false |
|
387 |
! |
|
388 |
||
389 |
fromFile:aFileName directory:dirName cached:cached |
|
244 | 390 |
"get the resource definitions from a file in a directory. |
391 |
Uncached low-level entry." |
|
392 |
||
393 |
|newPack| |
|
394 |
||
395 |
newPack := self new. |
|
7388 | 396 |
KeepStatisticsOnUsedKeys == true ifTrue:[ |
397 |
newPack rememberUsedKeys. |
|
398 |
]. |
|
244 | 399 |
newPack readFromFile:aFileName directory:dirName. |
4611 | 400 |
cached ifTrue:[ |
7388 | 401 |
self addToCache:newPack. |
4611 | 402 |
]. |
244 | 403 |
^ newPack |
0 | 404 |
! ! |
405 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
406 |
!ResourcePack class methodsFor:'private'! |
54 | 407 |
|
408 |
addToCache:aPack |
|
409 |
|idx| |
|
0 | 410 |
|
4084 | 411 |
Packs isNil ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
412 |
self initialize. |
4084 | 413 |
]. |
414 |
||
54 | 415 |
idx := Packs identityIndexOf:nil. |
416 |
idx == 0 ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
417 |
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
|
418 |
]. |
f7b6f15899ab
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
419 |
idx == 0 ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
420 |
" |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
421 |
throw away oldest |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
422 |
" |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
423 |
idx := Packs size. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
424 |
Packs replaceFrom:1 to:idx-1 with:Packs startingAt:2. |
54 | 425 |
]. |
5357 | 426 |
aPack at:'__language__' put:(UserPreferences current language,'_',UserPreferences current languageTerritory). |
4619 | 427 |
Packs at:idx put:aPack. |
428 |
||
429 |
"Modified: / 18-09-2006 / 19:12:12 / cg" |
|
54 | 430 |
! |
0 | 431 |
|
4093 | 432 |
searchCacheFor:aClassOrFileName |
4619 | 433 |
|sz "{ Class: SmallInteger }" lang| |
0 | 434 |
|
24 | 435 |
Packs isNil ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
436 |
self initialize. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
437 |
^ nil |
0 | 438 |
]. |
54 | 439 |
|
5357 | 440 |
lang := (UserPreferences current language,'_',UserPreferences current languageTerritory). |
4619 | 441 |
|
54 | 442 |
sz := Packs size. |
443 |
1 to:sz do:[:idx | |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
444 |
|aPack| |
54 | 445 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
446 |
aPack := Packs at:idx. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
447 |
(aPack notNil and:[aPack class ~~ SmallInteger]) ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
448 |
(aPack at:'__language__' ifAbsent:nil) = lang ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
449 |
aClassOrFileName = aPack packsClassOrFileName ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
450 |
" |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
451 |
bring to front for LRU |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
452 |
" |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
453 |
idx ~~ 1 ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
454 |
Packs replaceFrom:2 to:idx with:Packs startingAt:1. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
455 |
Packs at:1 put:aPack. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
456 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
457 |
^ aPack |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
458 |
] |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
459 |
] |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
460 |
] |
0 | 461 |
]. |
54 | 462 |
^ nil |
123 | 463 |
|
464 |
" |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
465 |
ResourcePack searchCacheFor:'TextView' |
123 | 466 |
" |
4619 | 467 |
|
468 |
"Modified: / 18-09-2006 / 19:13:13 / cg" |
|
54 | 469 |
! ! |
470 |
||
4509 | 471 |
!ResourcePack class methodsFor:'utilities'! |
472 |
||
473 |
extractEncodingFromLine:lineString |
|
474 |
|rest encoding| |
|
475 |
||
476 |
(lineString startsWith:'encoding') ifFalse:[^ nil]. |
|
477 |
||
478 |
rest := lineString copyFrom:9. |
|
479 |
rest := rest withoutSeparators. |
|
480 |
(rest startsWith:'#') ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
481 |
rest := rest copyFrom:2. |
4509 | 482 |
]. |
483 |
(rest startsWith:'''') ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
484 |
rest := rest copyFrom:2. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
485 |
(rest endsWith:'''') ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
486 |
rest := rest copyButLast:1. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
487 |
]. |
4509 | 488 |
]. |
489 |
encoding := rest asSymbol. |
|
490 |
^ encoding. |
|
491 |
! |
|
492 |
||
493 |
processResourceLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError for:aResourcePack |
|
494 |
"process a single valid line (i.e. #ifdef & #include has already been processed)" |
|
495 |
||
4510 | 496 |
self |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
497 |
processResourceLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError for:aResourcePack |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
498 |
keepUselessTranslations:false. |
4510 | 499 |
! |
500 |
||
501 |
processResourceLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError for:aResourcePack keepUselessTranslations:keepUselessTranslations |
|
502 |
"process a single valid line (i.e. #ifdef & #include has already been processed)" |
|
503 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
504 |
|name lineStream idx rest macroName value |
4670 | 505 |
conditional hasError decoder oldValue ignoreTranslation indirect| |
4509 | 506 |
|
6250 | 507 |
"/ Transcript showCR:lineString. |
4531 | 508 |
encodingSymbolOrEncoder notNil ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
509 |
encodingSymbolOrEncoder isSymbol ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
510 |
decoder := CharacterEncoder encoderFor:encodingSymbolOrEncoder ifAbsent:nil. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
511 |
decoder isNil ifTrue:[ decoder := CharacterEncoder nullEncoderInstance ]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
512 |
] ifFalse:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
513 |
decoder := encodingSymbolOrEncoder |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
514 |
]. |
4531 | 515 |
]. |
516 |
||
517 |
decoder notNil ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
518 |
lineStream := (decoder decodeString:lineString) readStream. |
4531 | 519 |
] ifFalse:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
520 |
lineStream := lineString readStream. |
4531 | 521 |
]. |
4509 | 522 |
lineStream signalAtEnd:false. |
523 |
lineStream skipSeparators. |
|
5080 | 524 |
|
4509 | 525 |
lineStream peek == $# ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
526 |
name := Array |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
527 |
readFrom:lineStream |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
528 |
onError:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
529 |
printError value:('invalid line <' , lineString , '>'). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
530 |
nil |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
531 |
]. |
4509 | 532 |
] ifFalse:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
533 |
lineStream peek == $' ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
534 |
name := String |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
535 |
readSmalltalkStringFrom:lineStream |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
536 |
onError:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
537 |
printError value:('invalid line <' , lineString , '>'). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
538 |
nil |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
539 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
540 |
] ifFalse:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
541 |
name := lineStream upToSeparator. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
542 |
]. |
4509 | 543 |
]. |
544 |
||
4510 | 545 |
name isNil ifTrue:[^ self ]. |
546 |
||
547 |
ignoreTranslation := false. |
|
548 |
hasError := false. |
|
4509 | 549 |
|
4510 | 550 |
lineStream skipSeparators. |
6113 | 551 |
idx := lineStream position + 1 + 1. |
4510 | 552 |
|
553 |
lineStream peek == $< ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
554 |
" |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
555 |
skip <type> if present |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
556 |
" |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
557 |
lineStream skipThrough:$>. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
558 |
lineStream skipSeparators. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
559 |
idx := lineStream position + 2. |
4510 | 560 |
]. |
4509 | 561 |
|
4670 | 562 |
conditional := indirect := false. |
4510 | 563 |
lineStream peek == $? ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
564 |
conditional := true. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
565 |
lineStream next. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
566 |
lineStream skipSeparators. |
4670 | 567 |
]. |
568 |
||
569 |
lineStream peek == $@ ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
570 |
indirect := true. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
571 |
lineStream next. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
572 |
lineStream skipSeparators. |
4510 | 573 |
]. |
4509 | 574 |
|
4510 | 575 |
lineStream peek == $= ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
576 |
lineStream next. |
4510 | 577 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
578 |
macroName := lineStream nextAlphaNumericWord. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
579 |
[lineStream peek == $.] whileTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
580 |
lineStream next. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
581 |
lineStream peek notNil ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
582 |
macroName := macroName , '.' , (lineStream nextAlphaNumericWord) |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
583 |
] |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
584 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
585 |
rest := lineStream upToEnd. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
586 |
value := aResourcePack at:macroName ifAbsent:nil. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
587 |
(value isNil) ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
588 |
hasError := true. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
589 |
printError value:('bad (nil-valued) macro: ' , macroName). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
590 |
]. |
4678
0d83cc874dc3
block value handling changed
Claus Gittinger <cg@exept.de>
parents:
4673
diff
changeset
|
591 |
"/ value isBlock ifTrue:[ |
0d83cc874dc3
block value handling changed
Claus Gittinger <cg@exept.de>
parents:
4673
diff
changeset
|
592 |
"/ value := value value |
0d83cc874dc3
block value handling changed
Claus Gittinger <cg@exept.de>
parents:
4673
diff
changeset
|
593 |
"/ ]. |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
594 |
rest isBlank ifFalse:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
595 |
value := Compiler evaluate:('self ' , rest) |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
596 |
receiver:value |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
597 |
notifying:nil |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
598 |
compile:false. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
599 |
(value == #Error) ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
600 |
hasError := true. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
601 |
printError value:('error in: "self ' , rest , '"'). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
602 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
603 |
"/ 'self ' print. rest print. ' -> ' print. value printCR. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
604 |
] |
4510 | 605 |
] ifFalse:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
606 |
lineStream peek == $' ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
607 |
value := String |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
608 |
readSmalltalkStringFrom:lineStream |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
609 |
onError:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
610 |
printError value:('invalid line <' , lineString , '>'). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
611 |
nil |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
612 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
613 |
"/ ' -> ' print. value printCR. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
614 |
] ifFalse:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
615 |
rest := lineStream upToEnd. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
616 |
[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
617 |
value := Compiler evaluate:rest compile:"true" false. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
618 |
] on:Error do:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
619 |
printError value:('invalid line <' , rest , '>'). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
620 |
"/ value := rest |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
621 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
622 |
"/ rest print. ' -> ' print. value printCR. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
623 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
624 |
(value == #Error) ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
625 |
hasError := true. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
626 |
printError value:('error in: "' , rest , '"'). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
627 |
] ifFalse:[ |
4531 | 628 |
"/ value isString ifTrue:[ |
629 |
"/ decoder notNil ifTrue:[ |
|
630 |
"/ value := decoder decodeString:value |
|
631 |
"/ ] |
|
632 |
"/ ] |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
633 |
] |
4510 | 634 |
]. |
635 |
||
5430
128e9b37fd8a
comment/format in: #processResourceLine:encoding:file:printErrorWith:for:
sr
parents:
5370
diff
changeset
|
636 |
"/ Transcript show:name; show:' -> '; showCR:value. |
128e9b37fd8a
comment/format in: #processResourceLine:encoding:file:printErrorWith:for:
sr
parents:
5370
diff
changeset
|
637 |
|
4510 | 638 |
hasError ifFalse:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
639 |
(conditional not |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
640 |
or:[(aResourcePack includesKey:name) not]) ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
641 |
name = value ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
642 |
keepUselessTranslations ifFalse:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
643 |
printError value:('useless resource: "' , name , '"'). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
644 |
ignoreTranslation := true |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
645 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
646 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
647 |
ignoreTranslation ifFalse:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
648 |
oldValue := aResourcePack at:name ifAbsent:nil. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
649 |
oldValue notNil ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
650 |
oldValue ~= value ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
651 |
printError value:('conflicting resource: "' , name , '"'). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
652 |
printError value:('oldValue: ' , oldValue printString). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
653 |
printError value:('newValue: ' , value printString). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
654 |
] ifFalse:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
655 |
printError value:('duplicate resource: "' , name , '"'). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
656 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
657 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
658 |
indirect ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
659 |
value := aResourcePack string:value. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
660 |
]. |
5431 | 661 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
662 |
DebugModifications == true ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
663 |
"/ for debugging only !! (not all primitive code is ready for immutableStrings) |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
664 |
value class == String ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
665 |
value := value asImmutableString. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
666 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
667 |
]. |
5431 | 668 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
669 |
aResourcePack at:name put:value. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
670 |
] |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
671 |
] |
4509 | 672 |
] |
4534
d71ca6ac7cbe
handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents:
4531
diff
changeset
|
673 |
|
6250 | 674 |
"Modified: / 06-02-2014 / 15:33:03 / cg" |
6661 | 675 |
! |
676 |
||
677 |
resourceFileEntryFor:keyString to:nationalString |
|
678 |
"generate a line for a translation file, which defines a translation |
|
679 |
from keyString to nationalString. |
|
680 |
Naivly, this could be a simple line containing the two storeStrings |
|
681 |
separated by a space. However, it is better to first cut of any leading |
|
682 |
and trailing spaces and special characters, such as ':*.,' etc." |
|
683 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
684 |
^ (self resourceFileStringFor:keyString),' ',(self resourceFileStringFor:nationalString) |
6661 | 685 |
! |
686 |
||
687 |
resourceFileStringFor:aString |
|
688 |
"generate a key or value entry for a translation file, for aString. |
|
689 |
Naivly, this could be a simple the storeString. |
|
690 |
However, it is better to first cut of any leading |
|
691 |
and trailing spaces and special characters, sch as ':*.,' etc." |
|
692 |
||
693 |
^ (self shortenedKeyFor:aString) storeString |
|
694 |
||
695 |
" |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
696 |
self resourceFileStringFor:' foo: ' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
697 |
self resourceFileStringFor:' foo bar: ' |
6661 | 698 |
" |
699 |
! |
|
700 |
||
701 |
shortenedKeyFor:aKey |
|
702 |
"if |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
703 |
aKey is '(...)', then return '...' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
704 |
if aKey is '[...]', then return '...' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
705 |
if aKey is '{...}', then return '...' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
706 |
if aKey starts or ends with any of '\:=.,?!! ', then return aKey without it |
6661 | 707 |
|
708 |
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
|
709 |
things like |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
710 |
'search' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
711 |
'search:' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
712 |
'search...' |
6661 | 713 |
" |
714 |
||
715 |
|idx idx1 idx2 first last keySize| |
|
716 |
||
717 |
first := aKey first. |
|
718 |
last := aKey last. |
|
719 |
keySize := aKey size. |
|
720 |
||
721 |
((first == $( and:[last == $) ]) |
|
722 |
or:[ (first == $[ and:[last == $] ]) |
|
723 |
or:[ (first == ${ and:[last == $} ]) ]]) ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
724 |
^ self shortenedKeyFor:(aKey copyFrom:2 to:keySize-1). |
6661 | 725 |
]. |
726 |
||
727 |
idx1 := aKey findFirst:[:ch | ch isSeparator not]. |
|
728 |
idx2 := aKey findLast:[:ch | ch isSeparator not] ifNone:keySize. |
|
729 |
(idx1 > 1 or:[idx2 < keySize]) ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
730 |
^ self shortenedKeyFor:(aKey copyFrom:idx1 to:idx2) |
6661 | 731 |
]. |
732 |
||
733 |
idx1 := aKey findFirst:[:ch | ('*:=.?!!,-><\' includes:ch) not]. |
|
734 |
idx2 := aKey findLast:[:ch | ('*:=.?!!,-><\' includes:ch) not] ifNone:keySize. |
|
735 |
(idx1 > 1 or:[idx2 < keySize]) ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
736 |
^ self shortenedKeyFor:(aKey copyFrom:idx1 to:idx2) |
6661 | 737 |
]. |
738 |
||
739 |
"/ change duplicated &'s to single |
|
740 |
(idx := aKey indexOf:$&) ~~ 0 ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
741 |
(aKey at:idx+1 ifAbsent:nil) ~~ $& ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
742 |
^ self shortenedKeyFor:(aKey copyTo:idx-1),(aKey copyFrom:idx+1). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
743 |
]. |
6661 | 744 |
]. |
745 |
^ aKey. |
|
746 |
||
747 |
" |
|
748 |
'abcde' findFirst:[:ch | 'bcd' includes:ch] |
|
749 |
'abcde' indexOfAny:'bcd' |
|
750 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
751 |
self shortenedKeyFor:'abc' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
752 |
self shortenedKeyFor:' abc ' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
753 |
self shortenedKeyFor:'(abc)' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
754 |
self shortenedKeyFor:'abc...' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
755 |
self shortenedKeyFor:'(abc...)' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
756 |
self shortenedKeyFor:'abc:*' |
6661 | 757 |
" |
4509 | 758 |
! ! |
759 |
||
0 | 760 |
!ResourcePack methodsFor:'accessing'! |
761 |
||
244 | 762 |
array:anArray |
763 |
"translate a collection of strings" |
|
0 | 764 |
|
244 | 765 |
^ anArray collect:[:r | self at:r default:r] |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
766 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
767 |
" |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
768 |
Launcher classResources array:#('file' 'classes') |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
769 |
" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
770 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
771 |
"Modified: / 29.1.1998 / 22:44:22 / cg" |
0 | 772 |
! |
773 |
||
2 | 774 |
at:aKey |
123 | 775 |
"translate a string" |
776 |
||
72 | 777 |
^ self at:aKey ifAbsent:aKey |
0 | 778 |
! |
779 |
||
780 |
at:aKey default:default |
|
123 | 781 |
"translate a string" |
782 |
||
72 | 783 |
^ self at:aKey ifAbsent:default |
0 | 784 |
! |
785 |
||
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
786 |
at:aKey ifAbsent:defaultValue |
4617 | 787 |
"translate a string; search here, in my projects pack and in my superpack(s)" |
788 |
||
789 |
|val pack projectPack alreadySearched| |
|
790 |
||
791 |
aKey isNil ifTrue:[ ^ defaultValue value ]. |
|
792 |
||
793 |
val := self localAt:aKey. |
|
794 |
val notNil ifTrue:[^ val]. |
|
795 |
||
796 |
(projectPack := self projectPack) notNil ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
797 |
val := projectPack localAt:aKey. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
798 |
val notNil ifTrue:[^ val]. |
4617 | 799 |
]. |
800 |
alreadySearched := Set new. |
|
801 |
projectPack notNil ifTrue:[ alreadySearched add:projectPack ]. |
|
802 |
||
803 |
pack := self superPack. |
|
804 |
[ pack notNil ] whileTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
805 |
val := pack localAt:aKey. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
806 |
val notNil ifTrue:[^ val]. |
4617 | 807 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
808 |
(projectPack := pack projectPack) notNil ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
809 |
(alreadySearched includes:projectPack) ifFalse:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
810 |
val := projectPack localAt:aKey. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
811 |
val notNil ifTrue:[^ val]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
812 |
alreadySearched add:projectPack. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
813 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
814 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
815 |
pack := pack superPack |
4617 | 816 |
]. |
817 |
||
4618 | 818 |
alreadySearched copy do:[:projectPack | |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
819 |
|p| |
4618 | 820 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
821 |
p := projectPack superPack. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
822 |
[p notNil and:[(alreadySearched includes:p) not]] whileTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
823 |
val := p localAt:aKey. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
824 |
val notNil ifTrue:[^ val]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
825 |
alreadySearched add:p. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
826 |
p := p superPack. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
827 |
]. |
4618 | 828 |
]. |
829 |
||
4617 | 830 |
^ defaultValue value |
831 |
||
4618 | 832 |
"Modified: / 18-09-2006 / 18:50:52 / cg" |
4617 | 833 |
! |
834 |
||
835 |
localAt:aKey |
|
4035 | 836 |
"translate a string. |
837 |
Some special 'intelligence' has been added: |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
838 |
if no value for aKey is found, |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
839 |
lookup aKey with first character caseChanged and change the results first characters case. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
840 |
or aKey is '(...)', then lookup ... wrap () around the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
841 |
or aKey is '[...]', then lookup ... wrap [] around the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
842 |
or aKey is '{...}', then lookup ... wrap {} around the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
843 |
or aKey starts with a '\', then lookup aKey without '\' and prepend '\' to the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
844 |
or aKey ends with a '\', then lookup aKey without '\' and append '\' to the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
845 |
or aKey ends with a ':', then lookup aKey without ':' and append ':' to the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
846 |
or aKey ends with a '=', then lookup aKey without '=' and append '=' to the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
847 |
or aKey ends with a '.', then lookup aKey without '.' and append '.' to the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
848 |
or aKey ends with a ',', then lookup aKey without ',' and append ',' to the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
849 |
or aKey ends with a '?', then lookup aKey without '?' and append '?' to the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
850 |
or aKey ends with a '!!', then lookup aKey without '!!' and append '!!' to the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
851 |
or aKey ends with a ' ', then lookup aKey without ' ' and append ' ' to the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
852 |
or aKey ends with a ' ...', then lookup aKey without ' ...' and append '...' to the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
853 |
or aKey ends with a '...', then lookup aKey without '...' and append '...' to the result. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
854 |
or aKey includes '&', then lookup aKey without '&'. |
4035 | 855 |
|
856 |
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
|
857 |
things like |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
858 |
'search' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
859 |
'search:' |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
860 |
'search...' |
4035 | 861 |
" |
123 | 862 |
|
5573 | 863 |
|val alternativeKey usedKey idx first last| |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
864 |
|
4617 | 865 |
val := super at:aKey ifAbsent:nil. |
4678
0d83cc874dc3
block value handling changed
Claus Gittinger <cg@exept.de>
parents:
4673
diff
changeset
|
866 |
val notNil ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
867 |
^ val value |
4678
0d83cc874dc3
block value handling changed
Claus Gittinger <cg@exept.de>
parents:
4673
diff
changeset
|
868 |
]. |
3549
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
869 |
|
4848 | 870 |
(aKey isString and:[aKey notEmpty]) ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
871 |
first := aKey first. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
872 |
last := aKey last. |
5573 | 873 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
874 |
"/ try with case-first swapped... |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
875 |
first isLetter ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
876 |
alternativeKey := first isUppercase |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
877 |
ifTrue:[aKey asLowercaseFirst] |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
878 |
ifFalse:[aKey asUppercaseFirst]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
879 |
val := super at:alternativeKey ifAbsent:nil. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
880 |
val notNil ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
881 |
first isUppercase ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
882 |
^ val asUppercaseFirst |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
883 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
884 |
^ val asLowercaseFirst. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
885 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
886 |
]. |
4617 | 887 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
888 |
((first == $( and:[last == $) ]) |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
889 |
or:[ (first == $[ and:[last == $] ]) |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
890 |
or:[ (first == ${ and:[last == $} ]) ]]) ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
891 |
usedKey := aKey copyFrom:2 to:aKey size-1. |
5593 | 892 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
893 |
val := self localAt:usedKey. "/ recursion |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
894 |
val notNil ifTrue:[^ first asString,val,last asString]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
895 |
]. |
5593 | 896 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
897 |
last == $. ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
898 |
(aKey endsWith:' ...') ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
899 |
usedKey := aKey copyButLast:4. |
5573 | 900 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
901 |
val := self localAt:usedKey. "/ recursion |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
902 |
val notNil ifTrue:[^ val , ' ...']. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
903 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
904 |
(aKey endsWith:'...') ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
905 |
usedKey := aKey copyButLast:3. |
5573 | 906 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
907 |
val := self localAt:usedKey. "/ recursion |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
908 |
val notNil ifTrue:[^ val , '...']. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
909 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
910 |
]. |
5573 | 911 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
912 |
first isSeparator ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
913 |
usedKey := aKey withoutLeadingSeparators. |
4634 | 914 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
915 |
val := self localAt:usedKey. "/ recursion |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
916 |
val notNil ifTrue:[^ (aKey copyTo:(aKey size - usedKey size)), val]. "/ prepend the stripped separators |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
917 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
918 |
last isSeparator ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
919 |
usedKey := aKey withoutTrailingSeparators. |
4634 | 920 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
921 |
val := self localAt:usedKey. "/ recursion |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
922 |
val notNil ifTrue:[^ val, (aKey copyFrom:usedKey size + 1)]. "/ append the stripped separators |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
923 |
]. |
4634 | 924 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
925 |
('*:=.?!!,-><\' includes:last) ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
926 |
aKey size >= 2 ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
927 |
usedKey := aKey copyButLast:1. |
4617 | 928 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
929 |
val := self localAt:usedKey. "/ recursion |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
930 |
val notNil ifTrue:[^ val copyWith:last]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
931 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
932 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
933 |
('*:=.?!!-><\' includes:first) ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
934 |
aKey size >= 2 ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
935 |
usedKey := aKey copyFrom:2. |
4634 | 936 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
937 |
val := self localAt:usedKey. "/ recursion |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
938 |
val notNil ifTrue:[^ first asString , val]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
939 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
940 |
]. |
4028 | 941 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
942 |
(first == $( and:[last == $)]) ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
943 |
usedKey := aKey copyFrom:2 to:(aKey size - 1). |
4028 | 944 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
945 |
val := self localAt:usedKey. "/ recursion |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
946 |
val notNil ifTrue:[^ '(' , val , ')']. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
947 |
]. |
4017 | 948 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
949 |
(idx := aKey indexOf:$&) ~~ 0 ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
950 |
(aKey at:idx+1 ifAbsent:nil) ~~ $& ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
951 |
usedKey := (aKey copyTo:idx-1) , (aKey copyFrom:idx+1). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
952 |
val := self localAt:usedKey. "/ recursion |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
953 |
val notNil ifTrue:[^ val]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
954 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
955 |
]. |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
956 |
]. |
4617 | 957 |
^ nil. |
4580 | 958 |
|
4617 | 959 |
"Created: / 18-09-2006 / 17:33:27 / cg" |
4796 | 960 |
"Modified: / 21-08-2007 / 21:18:12 / cg" |
5593 | 961 |
"Modified: / 05-08-2010 / 16:52:32 / sr" |
2 | 962 |
! |
963 |
||
964 |
name:aKey default:default |
|
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
965 |
"translate a string. |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
966 |
Obsolete - use #string:default:" |
123 | 967 |
|
4844 | 968 |
<resource: #obsolete> |
969 |
||
72 | 970 |
^ self at:aKey ifAbsent:default |
2 | 971 |
! |
972 |
||
0 | 973 |
string:s |
3097 | 974 |
"translate (retrieve) a string - if not present, return s" |
123 | 975 |
|
72 | 976 |
^ self at:s ifAbsent:s |
3097 | 977 |
|
978 |
" |
|
979 |
NewLauncher classResources |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
980 |
string:'LICENCEFILE' |
3097 | 981 |
" |
0 | 982 |
! |
983 |
||
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
984 |
string:s default:defaultString |
3097 | 985 |
"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
|
986 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
987 |
^ self at:s ifAbsent:defaultString |
3097 | 988 |
|
989 |
" |
|
990 |
NewLauncher classResources |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
991 |
string:'fooBar' default:'Hello world' |
3097 | 992 |
" |
993 |
||
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
994 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
995 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
996 |
string:s default:defaultString with:arg |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
997 |
"translate and expand arg" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
998 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
999 |
^ self string:s default:defaultString withArgs:(Array with:arg) |
3097 | 1000 |
|
1001 |
" |
|
1002 |
NewLauncher classResources |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1003 |
string:'%1 fooBar' default:'Hello %1' with:'foo' |
3097 | 1004 |
" |
1005 |
||
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1006 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1007 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1008 |
string:s default:defaultString with:arg1 with:arg2 |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1009 |
"translate and expand args" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1010 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1011 |
^ self string:s default:defaultString withArgs:(Array with:arg1 with:arg2) |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1012 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1013 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1014 |
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
|
1015 |
"translate and expand args" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1016 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1017 |
^ self string:s default:defaultString withArgs:(Array with:arg1 with:arg2 with:arg3) |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1018 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1019 |
"Created: 9.12.1995 / 19:08:50 / cg" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1020 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1021 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1022 |
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
|
1023 |
"translate and expand args" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1024 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1025 |
^ self string:s default:defaultString withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1026 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1027 |
"Created: 9.9.1996 / 18:52:14 / cg" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1028 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1029 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1030 |
string:s default:defaultString withArgs:argArray |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1031 |
"translate and expand args" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1032 |
|
5070 | 1033 |
|template| |
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1034 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1035 |
template := self at:s ifAbsent:defaultString. |
5070 | 1036 |
^ template expandPlaceholdersWith:argArray. |
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1037 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1038 |
|
0 | 1039 |
string:s with:arg |
123 | 1040 |
"translate and expand arg" |
1041 |
||
0 | 1042 |
^ self string:s withArgs:(Array with:arg) |
1043 |
! |
|
1044 |
||
1045 |
string:s with:arg1 with:arg2 |
|
123 | 1046 |
"translate and expand args" |
1047 |
||
0 | 1048 |
^ self string:s withArgs:(Array with:arg1 with:arg2) |
1049 |
! |
|
1050 |
||
292
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1051 |
string:s with:arg1 with:arg2 with:arg3 |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1052 |
"translate and expand args" |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1053 |
|
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1054 |
^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3) |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1055 |
|
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1056 |
"Created: 9.12.1995 / 19:08:50 / cg" |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1057 |
! |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
1058 |
|
1042 | 1059 |
string:s with:arg1 with:arg2 with:arg3 with:arg4 |
1060 |
"translate and expand args" |
|
1061 |
||
1062 |
^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
|
1063 |
||
1064 |
"Created: 9.9.1996 / 18:52:14 / cg" |
|
1065 |
! |
|
1066 |
||
3184 | 1067 |
string:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
1068 |
"translate and expand args" |
|
1069 |
||
1070 |
^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
|
1071 |
||
1072 |
! |
|
1073 |
||
5652 | 1074 |
string:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 |
1075 |
"translate and expand args" |
|
1076 |
||
1077 |
^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6) |
|
1078 |
||
1079 |
"Created: / 13-11-2010 / 11:35:00 / cg" |
|
1080 |
! |
|
1081 |
||
1082 |
string:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 |
|
1083 |
"translate and expand args" |
|
1084 |
||
1085 |
^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7) |
|
1086 |
||
1087 |
"Created: / 13-11-2010 / 11:35:07 / cg" |
|
1088 |
! |
|
1089 |
||
0 | 1090 |
string:s withArgs:argArray |
4932
b19b928b0026
Allow (and insert) Texts as arguments in #string:with:
Stefan Vogel <sv@exept.de>
parents:
4848
diff
changeset
|
1091 |
"translate and expand args - allow text as arguments" |
123 | 1092 |
|
5069 | 1093 |
|template| |
0 | 1094 |
|
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
1095 |
template := self at:s ifAbsent:s. |
5069 | 1096 |
^ template expandPlaceholdersWith:argArray. |
4932
b19b928b0026
Allow (and insert) Texts as arguments in #string:with:
Stefan Vogel <sv@exept.de>
parents:
4848
diff
changeset
|
1097 |
|
5069 | 1098 |
|
1099 |
||
1100 |
||
1101 |
||
1102 |
||
1103 |
||
1104 |
||
3823 | 1105 |
! |
1106 |
||
4402 | 1107 |
stringWithCRs:s |
1108 |
"translate (retrieve) a string - if not present, return s" |
|
1109 |
||
1110 |
^ (self string:s) withCRs |
|
1111 |
||
1112 |
" |
|
1113 |
NewLauncher classResources |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1114 |
stringWithCRs:'LICENCEFILE' |
4402 | 1115 |
" |
1116 |
! |
|
1117 |
||
3823 | 1118 |
stringWithCRs:s with:arg |
1119 |
"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
|
1120 |
CR-replacement is donw before args are inserted |
3823 | 1121 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1122 |
||
1123 |
^ self stringWithCRs:s withArgs:(Array with:arg) |
|
1124 |
||
1125 |
"Modified: / 21.3.2003 / 14:22:09 / cg" |
|
1126 |
! |
|
1127 |
||
1128 |
stringWithCRs:s with:arg1 with:arg2 |
|
1129 |
"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
|
1130 |
CR-replacement is donw before args are inserted |
3823 | 1131 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1132 |
||
1133 |
^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2) |
|
1134 |
||
1135 |
"Modified: / 21.3.2003 / 14:22:06 / cg" |
|
1136 |
! |
|
1137 |
||
1138 |
stringWithCRs:s with:arg1 with:arg2 with:arg3 |
|
1139 |
"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
|
1140 |
CR-replacement is donw before args are inserted |
3823 | 1141 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1142 |
||
1143 |
^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3) |
|
1144 |
||
1145 |
"Created: 9.12.1995 / 19:08:50 / cg" |
|
1146 |
! |
|
1147 |
||
1148 |
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4 |
|
1149 |
"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
|
1150 |
CR-replacement is donw before args are inserted |
3823 | 1151 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1152 |
||
1153 |
^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
|
1154 |
||
1155 |
"Modified: / 21.3.2003 / 14:21:48 / cg" |
|
1156 |
! |
|
1157 |
||
1158 |
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
|
1159 |
"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
|
1160 |
CR-replacement is donw before args are inserted |
3823 | 1161 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1162 |
||
1163 |
^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
|
1164 |
||
1165 |
"Modified: / 21.3.2003 / 14:21:55 / cg" |
|
1166 |
! |
|
1167 |
||
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1168 |
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 |
5652 | 1169 |
"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
|
1170 |
CR-replacement is donw before args are inserted |
5652 | 1171 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1172 |
||
1173 |
^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6) |
|
1174 |
||
1175 |
"Created: / 13-11-2010 / 11:35:30 / cg" |
|
1176 |
! |
|
1177 |
||
1178 |
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 |
|
1179 |
"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
|
1180 |
CR-replacement is donw before args are inserted |
5652 | 1181 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1182 |
||
1183 |
^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7) |
|
1184 |
||
1185 |
"Created: / 13-11-2010 / 11:35:20 / cg" |
|
1186 |
! |
|
1187 |
||
3823 | 1188 |
stringWithCRs:s withArgs:argArray |
1189 |
"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
|
1190 |
CR-replacement is done before args are inserted |
3823 | 1191 |
i.e. if any arg contains a backslash (DOS filenames), those are not translated." |
1192 |
||
5070 | 1193 |
|template| |
3823 | 1194 |
|
1195 |
template := self at:s ifAbsent:s. |
|
5070 | 1196 |
^ template withCRs expandPlaceholdersWith:argArray. |
6174 | 1197 |
! |
1198 |
||
1199 |
whichPackIncludesKey:aKey |
|
1200 |
"for debugging: return the pack (alogn the super-pack chain), which |
|
1201 |
has a translation for a string" |
|
1202 |
||
1203 |
|val pack projectPack alreadySearched| |
|
1204 |
||
1205 |
aKey isNil ifTrue:[ ^ nil ]. |
|
1206 |
||
1207 |
val := self localAt:aKey. |
|
1208 |
val notNil ifTrue:[^ self]. |
|
1209 |
||
1210 |
(projectPack := self projectPack) notNil ifTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1211 |
val := projectPack localAt:aKey. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1212 |
val notNil ifTrue:[^ projectPack]. |
6174 | 1213 |
]. |
1214 |
alreadySearched := Set new. |
|
1215 |
projectPack notNil ifTrue:[ alreadySearched add:projectPack ]. |
|
1216 |
||
1217 |
pack := self superPack. |
|
1218 |
[ pack notNil ] whileTrue:[ |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1219 |
val := pack localAt:aKey. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1220 |
val notNil ifTrue:[^ pack]. |
6174 | 1221 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1222 |
(projectPack := pack projectPack) notNil ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1223 |
(alreadySearched includes:projectPack) ifFalse:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1224 |
val := projectPack localAt:aKey. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1225 |
val notNil ifTrue:[^ projectPack]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1226 |
alreadySearched add:projectPack. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1227 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1228 |
]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1229 |
pack := pack superPack |
6174 | 1230 |
]. |
1231 |
||
1232 |
alreadySearched copy do:[:projectPack | |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1233 |
|p| |
6174 | 1234 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1235 |
p := projectPack superPack. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1236 |
[p notNil and:[(alreadySearched includes:p) not]] whileTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1237 |
val := p localAt:aKey. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1238 |
val notNil ifTrue:[^ p]. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1239 |
alreadySearched add:p. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1240 |
p := p superPack. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1241 |
]. |
6174 | 1242 |
]. |
1243 |
||
1244 |
^ nil |
|
0 | 1245 |
! ! |
1246 |
||
3317 | 1247 |
!ResourcePack methodsFor:'accessing-internals'! |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1248 |
|
7388 | 1249 |
forgetUsedKeys |
1250 |
"stop keeping a statistic on which kes are actually used" |
|
1251 |
||
1252 |
usedKeys := nil. |
|
1253 |
! |
|
1254 |
||
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1255 |
name:aKey |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1256 |
"translate a string" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1257 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1258 |
^ self at:aKey ifAbsent:aKey |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1259 |
! |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1260 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1261 |
packsClassName |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1262 |
^ packsClassName |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1263 |
! |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1264 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1265 |
packsClassName:aString |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1266 |
packsClassName := aString |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1267 |
! |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1268 |
|
4093 | 1269 |
packsClassOrFileName |
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1270 |
"old: should no longer be used to access the filename; see packsFileName" |
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1271 |
|
4093 | 1272 |
^ packsClassName |
1273 |
! |
|
1274 |
||
1275 |
packsClassOrFileName:aString |
|
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1276 |
"old: should no longer be used to access the filename; see packsFileName" |
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1277 |
|
4093 | 1278 |
packsClassName := aString |
1279 |
! |
|
1280 |
||
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1281 |
packsFileName |
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1282 |
^ packsFileName |
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1283 |
! |
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1284 |
|
4617 | 1285 |
projectPack |
1286 |
^ projectPack |
|
1287 |
||
1288 |
"Created: / 18-09-2006 / 17:38:07 / cg" |
|
1289 |
! |
|
1290 |
||
4085 | 1291 |
projectPack:anotherResourcePack |
1292 |
projectPack := anotherResourcePack |
|
1293 |
||
1294 |
"Created: / 29.1.1998 / 22:43:09 / cg" |
|
1295 |
! |
|
1296 |
||
7388 | 1297 |
rememberUsedKeys |
1298 |
"start keeping a statistic on which kes are actually used" |
|
1299 |
||
1300 |
usedKeys := Set new. |
|
1301 |
! |
|
1302 |
||
4617 | 1303 |
superPack |
1304 |
^ superPack |
|
1305 |
||
1306 |
"Created: / 18-09-2006 / 17:38:12 / cg" |
|
1307 |
! |
|
1308 |
||
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1309 |
superPack:anotherResourcePack |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1310 |
superPack := anotherResourcePack |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1311 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1312 |
"Created: / 29.1.1998 / 22:43:09 / cg" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1313 |
! ! |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1314 |
|
0 | 1315 |
!ResourcePack methodsFor:'file reading'! |
1316 |
||
684 | 1317 |
fileReadFailed |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1318 |
"return true, if the pack does not really contain |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1319 |
valid translations, since the fileRead failed. |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1320 |
However, all inherited translations are still available |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1321 |
through the receiver" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1322 |
|
687 | 1323 |
^ fileReadFailed ~~ false |
684 | 1324 |
|
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1325 |
"Created: / 14.5.1996 / 10:19:26 / cg" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
1326 |
"Modified: / 29.1.1998 / 22:46:38 / cg" |
684 | 1327 |
! |
1328 |
||
1894
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1329 |
nonexistingFileRead |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1330 |
"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
|
1331 |
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
|
1332 |
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
|
1333 |
|
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1334 |
^ nil |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1335 |
|
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1336 |
"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
|
1337 |
! |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
1338 |
|
4332 | 1339 |
processLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError |
145 | 1340 |
"process a single valid line (i.e. #ifdef & #include has already been processed)" |
1341 |
||
4509 | 1342 |
self class |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1343 |
processResourceLine:lineString |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1344 |
encoding:encodingSymbolOrEncoder |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1345 |
file:fileName |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1346 |
printErrorWith:printError |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1347 |
for:self |
144 | 1348 |
! |
1349 |
||
244 | 1350 |
readFromFile:fileName directory:dirName |
1351 |
"read definitions from a file in a directory" |
|
1352 |
||
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1353 |
|triedFilename inStream ok| |
244 | 1354 |
|
686 | 1355 |
fileReadFailed := false. |
5781
fc35ed4fd223
changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents:
5653
diff
changeset
|
1356 |
"/ 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
|
1357 |
"/ (happens when da.rs is not present in libbasic/resources.rs) |
fc35ed4fd223
changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents:
5653
diff
changeset
|
1358 |
ExternalStream openErrorSignal handle:[:ex | |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1359 |
Transcript showCR:'ResourcePack: failed to open file: ',fileName asString,' in ',dirName asString. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1360 |
inStream := nil. |
5781
fc35ed4fd223
changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents:
5653
diff
changeset
|
1361 |
] do:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1362 |
dirName = 'resources' ifTrue:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1363 |
inStream := Smalltalk resourceFileStreamFor:fileName |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1364 |
] ifFalse:[ |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1365 |
inStream := Smalltalk systemFileStreamFor: |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1366 |
(dirName isNil |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1367 |
ifTrue:[fileName] |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1368 |
ifFalse:[dirName asFilename construct:fileName]). |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1369 |
]. |
244 | 1370 |
]. |
5781
fc35ed4fd223
changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents:
5653
diff
changeset
|
1371 |
|
244 | 1372 |
inStream isNil ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1373 |
" |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1374 |
an empty pack |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1375 |
" |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1376 |
^ self nonexistingFileRead |
244 | 1377 |
]. |
2996 | 1378 |
|
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1379 |
triedFilename := inStream pathName. |
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1380 |
[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1381 |
ok := self readFromResourceStream:inStream in:(triedFilename asFilename directoryName). |
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1382 |
] ensure:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1383 |
inStream close. |
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1384 |
]. |
686 | 1385 |
|
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1386 |
ok ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1387 |
packsFileName := triedFilename |
5951
61a41352ce81
remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents:
5826
diff
changeset
|
1388 |
] ifFalse:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1389 |
fileReadFailed := true. |
684 | 1390 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1391 |
('ResourcePack [warning]: "' , triedFilename , '" contains error(s) - data may be incomplete.') errorPrintCR. |
244 | 1392 |
]. |
1393 |
||
5781
fc35ed4fd223
changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents:
5653
diff
changeset
|
1394 |
"Modified: / 20-08-2011 / 17:10:02 / cg" |
244 | 1395 |
! |
1396 |
||
72 | 1397 |
readFromResourceStream:inStream in:dirName |
4848 | 1398 |
"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
|
1399 |
specify where #include files are searched for. |
0f942dafc85a
gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents:
177
diff
changeset
|
1400 |
Return true, if the style sheet could be read without errors, false otherwise." |
145 | 1401 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1402 |
|lineString l lineNumber rest value ifLevel skipping first ok encoding decoder pack errorHandler |
4947 | 1403 |
printError fileName pushedSkipValues| |
4058 | 1404 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1405 |
fileName := (inStream isFileStream |
6992 | 1406 |
ifTrue:[inStream pathName asFilename baseName] |
1407 |
ifFalse:['---']). |
|
4058 | 1408 |
|
1409 |
printError := [:message | |
|
6992 | 1410 |
'ResourcePack [warning]: ' errorPrint. |
1411 |
message errorPrint. |
|
1412 |
' in file:' errorPrint. |
|
1413 |
fileName errorPrint. |
|
1414 |
' line: ' errorPrint. |
|
1415 |
lineNumber errorPrintCR |
|
1416 |
]. |
|
4058 | 1417 |
|
1418 |
printError := [:message | ]. |
|
462
423f8426fefc
added #encoding directive (I am lazy)
Claus Gittinger <cg@exept.de>
parents:
444
diff
changeset
|
1419 |
|
423f8426fefc
added #encoding directive (I am lazy)
Claus Gittinger <cg@exept.de>
parents:
444
diff
changeset
|
1420 |
encoding := nil. |
0 | 1421 |
|
210
0f942dafc85a
gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents:
177
diff
changeset
|
1422 |
ok := true. |
0 | 1423 |
ifLevel := 0. |
1424 |
skipping := false. |
|
4058 | 1425 |
lineNumber := 0. |
4947 | 1426 |
pushedSkipValues := OrderedCollection new. |
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
1427 |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1428 |
errorHandler := [:ex | |
6992 | 1429 |
|con| |
4947 | 1430 |
|
6992 | 1431 |
Transcript showCR:('ResourcePack [warning]: ''' , ex description , '''') "errorPrintCR". |
1432 |
Transcript showCR:('ResourcePack [info]: file: ' , inStream pathName printString , ' line: ' , lineNumber printString , ': ''' , lineString , '''') "errorPrintCR". |
|
1433 |
con := ex suspendedContext. |
|
1434 |
Transcript showCR:('ResourcePack [info]: in: ' , con fullPrintString) "errorPrintCR". |
|
1435 |
con := con sender. |
|
1436 |
Transcript showCR:('ResourcePack [info]: : ' , con fullPrintString) "errorPrintCR". |
|
7963
76834c6940c7
ResourcePack: print show full stack trace in case of error when reading
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7649
diff
changeset
|
1437 |
[ con notNil ] whileTrue: [ |
76834c6940c7
ResourcePack: print show full stack trace in case of error when reading
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7649
diff
changeset
|
1438 |
con := con sender. |
76834c6940c7
ResourcePack: print show full stack trace in case of error when reading
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7649
diff
changeset
|
1439 |
Transcript showCR:('ResourcePack [info]: : ' , con fullPrintString) "errorPrintCR". |
76834c6940c7
ResourcePack: print show full stack trace in case of error when reading
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7649
diff
changeset
|
1440 |
]. |
6992 | 1441 |
value := nil. |
1442 |
ok := false. |
|
1443 |
]. |
|
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
1444 |
|
0 | 1445 |
[inStream atEnd] whileFalse:[ |
6992 | 1446 |
lineString := inStream nextLine. lineNumber := lineNumber + 1. |
1447 |
[lineString notNil and:[lineString endsWith:$\]] whileTrue:[ |
|
1448 |
lineString := lineString copyButLast:1. |
|
1449 |
l := inStream nextLine. lineNumber := lineNumber + 1. |
|
1450 |
l notNil ifTrue:[ |
|
1451 |
lineString := lineString , l. |
|
1452 |
]. |
|
1453 |
]. |
|
177 | 1454 |
|
6992 | 1455 |
(lineString size > 0) ifTrue:[ |
1456 |
first := lineString at:1. |
|
1457 |
"/ |
|
1458 |
"/ for your convenience: treat both ';' AND '"/' as comment-line |
|
1459 |
"/ |
|
1460 |
((first == $;) or:[lineString startsWith:'"/']) ifFalse:[ |
|
1461 |
((first == $#) and:[(lineString startsWith:'#(') not]) ifTrue:[ |
|
1462 |
"/ a directive |
|
1463 |
lineString := (lineString copyFrom:2) withoutSpaces. |
|
72 | 1464 |
|
6992 | 1465 |
(lineString startsWith:'if') ifTrue:[ |
1466 |
pushedSkipValues add:skipping. |
|
1467 |
skipping ifFalse:[ |
|
1468 |
rest := lineString copyFrom:3. |
|
1469 |
Error, UserInformation |
|
1470 |
handle:errorHandler |
|
1471 |
do:[ |
|
1472 |
value := Compiler evaluate:rest compile:false. |
|
1473 |
]. |
|
1474 |
(value == #Error) ifTrue:[ |
|
1475 |
printError value:('error in resource:' , lineString). |
|
1476 |
]. |
|
1477 |
(value == false) ifTrue:[ |
|
1478 |
skipping := true |
|
1479 |
] |
|
1480 |
]. |
|
1481 |
ifLevel := ifLevel + 1 |
|
1482 |
] ifFalse:[ |
|
1483 |
(lineString startsWith:'endif') ifTrue:[ |
|
1484 |
ifLevel == 0 ifTrue:[ |
|
1485 |
printError value:('if/endif nesting error'). |
|
1486 |
] ifFalse:[ |
|
1487 |
ifLevel := ifLevel - 1. |
|
1488 |
skipping := pushedSkipValues removeLast. |
|
1489 |
] |
|
1490 |
] ifFalse:[ |
|
1491 |
(lineString startsWith:'else') ifTrue:[ |
|
1492 |
(pushedSkipValues includes:true) ifFalse:[ |
|
1493 |
skipping := skipping not |
|
1494 |
] |
|
1495 |
] ifFalse:[ |
|
1496 |
skipping ifFalse:[ |
|
1497 |
(lineString startsWith:'superpack') ifTrue:[ |
|
1498 |
rest := lineString copyFrom:('superpack' size + 1). |
|
1499 |
value := Compiler evaluate:rest compile:false. |
|
1500 |
(value isKindOf:ResourcePack) ifTrue:[ |
|
1501 |
superPack := value |
|
1502 |
] |
|
1503 |
] ifFalse:[ |
|
1504 |
(lineString startsWith:'include') ifTrue:[ |
|
1505 |
(lineString startsWith:'includeResourcesFor') ifTrue:[ |
|
1506 |
"/ include those resources ... |
|
1507 |
rest := lineString copyFrom:('includeResourcesFor' size + 1). |
|
1508 |
value := Compiler evaluate:rest compile:false. |
|
1509 |
value isBehavior ifTrue:[ |
|
1510 |
pack := self class for:value. |
|
1511 |
pack notNil ifTrue:[ |
|
1512 |
self addAll:pack. |
|
1513 |
] |
|
1514 |
] |
|
1515 |
] ifFalse:[ |
|
1516 |
rest := lineString copyFrom:('include' size + 1). |
|
1517 |
value := Compiler evaluate:rest compile:false. |
|
1518 |
value isString ifFalse:[ |
|
1519 |
printError value:('bad include filename: ' , value printString, ' "',lineString,'"'). |
|
1520 |
] ifTrue:[ |
|
1521 |
self readFromFile:value directory:dirName |
|
1522 |
] |
|
1523 |
] |
|
1524 |
] ifFalse:[ |
|
1525 |
(lineString startsWith:'encoding') ifTrue:[ |
|
4848 | 1526 |
"/decoder notNil ifTrue:[self halt:'oops - encoding change in file']. |
6992 | 1527 |
encoding := self class extractEncodingFromLine:lineString. |
1528 |
decoder := CharacterEncoder encoderFor:encoding ifAbsent:nil. |
|
1529 |
] |
|
1530 |
] |
|
1531 |
] |
|
1532 |
] |
|
1533 |
] |
|
1534 |
] |
|
1535 |
]. |
|
1536 |
] ifFalse:[ |
|
1537 |
skipping ifFalse:[ |
|
1538 |
Error, UserInformation |
|
1539 |
handle:errorHandler |
|
1540 |
do:[ |
|
1541 |
(lineString at:1) == $!! ifTrue:[ |
|
1542 |
"/ evaluate the rest |
|
1543 |
Compiler evaluate:(lineString copyFrom:2) |
|
1544 |
receiver:self |
|
1545 |
notifying:nil |
|
1546 |
compile:false. |
|
1547 |
] ifFalse:[ |
|
1548 |
"/ process as resource |
|
1549 |
self |
|
1550 |
processLine:lineString |
|
1551 |
encoding:decoder |
|
1552 |
file:(inStream isFileStream |
|
1553 |
ifTrue:[inStream pathName] |
|
1554 |
ifFalse:['---']) |
|
1555 |
printErrorWith:printError |
|
1556 |
]] |
|
1557 |
] |
|
1558 |
] |
|
1559 |
] |
|
1560 |
] |
|
0 | 1561 |
]. |
210
0f942dafc85a
gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents:
177
diff
changeset
|
1562 |
^ ok |
177 | 1563 |
|
4534
d71ca6ac7cbe
handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents:
4531
diff
changeset
|
1564 |
"Modified: / 31-08-1995 / 02:33:45 / claus" |
4619 | 1565 |
"Modified: / 18-09-2006 / 20:35:37 / cg" |
7963
76834c6940c7
ResourcePack: print show full stack trace in case of error when reading
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7649
diff
changeset
|
1566 |
"Modified: / 27-02-2017 / 15:23:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 1567 |
! ! |
1568 |
||
4093 | 1569 |
!ResourcePack methodsFor:'printing & storing'! |
1570 |
||
5603
0945abfddb9a
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
5593
diff
changeset
|
1571 |
displayOn:aGCOrStream |
0945abfddb9a
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
5593
diff
changeset
|
1572 |
|
0945abfddb9a
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
5593
diff
changeset
|
1573 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
0945abfddb9a
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
5593
diff
changeset
|
1574 |
"/ ST/X (and some old ST80's) mean: draw-yourself on a GC. |
6545 | 1575 |
(aGCOrStream isStream) ifTrue:[ |
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1576 |
aGCOrStream nextPutAll:'ResourcePack for: '. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1577 |
packsClassName printOn:aGCOrStream. |
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1578 |
^ self. |
5603
0945abfddb9a
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
5593
diff
changeset
|
1579 |
]. |
0945abfddb9a
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
5593
diff
changeset
|
1580 |
|
0945abfddb9a
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
5593
diff
changeset
|
1581 |
^ super displayOn:aGCOrStream |
4093 | 1582 |
! ! |
1583 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1584 |
!ResourcePack class methodsFor:'documentation'! |
251 | 1585 |
|
1586 |
version |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1587 |
^ '$Header$' |
5357 | 1588 |
! |
1589 |
||
1590 |
version_CVS |
|
6887
b10262d21ed1
linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents:
6799
diff
changeset
|
1591 |
^ '$Header$' |
7963
76834c6940c7
ResourcePack: print show full stack trace in case of error when reading
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7649
diff
changeset
|
1592 |
! |
76834c6940c7
ResourcePack: print show full stack trace in case of error when reading
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7649
diff
changeset
|
1593 |
|
76834c6940c7
ResourcePack: print show full stack trace in case of error when reading
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7649
diff
changeset
|
1594 |
version_HG |
76834c6940c7
ResourcePack: print show full stack trace in case of error when reading
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7649
diff
changeset
|
1595 |
|
76834c6940c7
ResourcePack: print show full stack trace in case of error when reading
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7649
diff
changeset
|
1596 |
^ '$Changeset: <not expanded> $' |
251 | 1597 |
! ! |
3769 | 1598 |
|
6051
f01078ce8c2c
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
5951
diff
changeset
|
1599 |
|
0 | 1600 |
ResourcePack initialize! |