ResourcePack.st
author Stefan Vogel <sv@exept.de>
Fri, 02 Nov 2007 19:01:48 +0100
changeset 4835 1f64020798d9
parent 4796 c17e24be80c1
child 4844 38faa6eaaf26
permissions -rw-r--r--
changed #readFromResourceStream:in: More explicit debug messages when parsing resource files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
claus
parents: 2
diff changeset
     1
"
claus
parents: 2
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
     3
	      All Rights Reserved
5
claus
parents: 2
diff changeset
     4
claus
parents: 2
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents: 2
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents: 2
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents: 2
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents: 2
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents: 2
diff changeset
    10
 hereby transferred.
claus
parents: 2
diff changeset
    11
"
3263
bd92a12c9316 category changes
Claus Gittinger <cg@exept.de>
parents: 3184
diff changeset
    12
"{ Package: 'stx:libview' }"
bd92a12c9316 category changes
Claus Gittinger <cg@exept.de>
parents: 3184
diff changeset
    13
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    14
Dictionary subclass:#ResourcePack
4085
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
    15
	instanceVariableNames:'packsClassName fileReadFailed superPack projectPack'
308
54fa63d274fa also allow "/ for comment lines
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    16
	classVariableNames:'Packs'
54fa63d274fa also allow "/ for comment lines
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    17
	poolDictionaries:''
3484
d21aad9e7db9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3422
diff changeset
    18
	category:'Interface-Internationalization'
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    19
!
48194c26a46c Initial revision
claus
parents:
diff changeset
    20
1173
86a212598655 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
    21
!ResourcePack class methodsFor:'documentation'!
46
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    22
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    23
copyright
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    24
"
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    25
 COPYRIGHT (c) 1993 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
    26
	      All Rights Reserved
5
claus
parents: 2
diff changeset
    27
46
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    28
 This software is furnished under a license and may be used
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    29
 only in accordance with the terms of that license and with the
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    31
 be provided or otherwise made available to, or used by, any
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    32
 other person.  No title to or ownership of the software is
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    33
 hereby transferred.
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    34
"
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    35
!
5
claus
parents: 2
diff changeset
    36
46
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    37
documentation
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    38
"
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    39
    This class supports easy customization of smalltalk code (i.e. internationalization
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    40
    and viewStyle adaption).
145
claus
parents: 144
diff changeset
    41
    ResourcePacks are class specific, meaning that every subclass of View
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    42
    and ApplicationModel has an instance of ResourcePack (instVar called 'resources') 
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    43
    which is created when the first instance of the view/app is created,
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    44
    and cached in a class-instVar (so the file is only read once).
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
    45
50
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    46
    The resourcePack consists of a mapping from strings to values, which are
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    47
    then used in labels, buttons, menus etc.
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    48
    The resourcePack initializes itself from a file found in 'resources/<className>.rs',
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    49
    where 'className' is built by the usual abbreviation mechanism (see abbrev-files).
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    50
50
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    51
    Conditional mappings are possible, by including lines as:
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
    52
	#if <expression>
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
    53
	#endif
50
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    54
    in the resourcefile. Example:
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    55
    file 'foo.rs':
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
    56
	#if Language == #de
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
    57
	'abort' 'Abbruch'
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
    58
	#endif
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
    59
	#if Language == #fr
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
    60
	'abort' 'canceller'
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
    61
	#endif
145
claus
parents: 144
diff changeset
    62
claus
parents: 144
diff changeset
    63
    the corresponding resource-strings are accessed (from methods within the class)
claus
parents: 144
diff changeset
    64
    using:
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
    65
	resources string:'abort'
145
claus
parents: 144
diff changeset
    66
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
    67
    returning the mapped string (i.e. 'Abbruch' if the global Language is set
3422
f00c788fa81f Comment only
Stefan Vogel <sv@exept.de>
parents: 3407
diff changeset
    68
    to #de)..
145
claus
parents: 144
diff changeset
    69
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    70
    If no corresponding entry is found in the resources, the key is returned;
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    71
    alternatively, use:
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
    72
	resources string:'foo' default:'bar'
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    73
    which returns 'bar', if no resource definition for 'foo' is found.
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    74
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
    75
    Translations can also include arguments, such as:
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
    76
	resources string:'really delete %1' with:fileName
145
claus
parents: 144
diff changeset
    77
claus
parents: 144
diff changeset
    78
    This scheme has the advantage, that you can write your programs using your
claus
parents: 144
diff changeset
    79
    native language strings. Later, when new languages are to be supported,
claus
parents: 144
diff changeset
    80
    simply create a resource file for the class and add translations for
claus
parents: 144
diff changeset
    81
    all those strings. (find the keys by looking at users of resource or senders
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    82
    of 'string:*').
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    83
    Notice, that the grammar of different languages may imply a reordering,
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    84
    so the above string becomes the german 'wollen Sie %1 wirklich löschen';
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    85
    so using percent-placeholders is much better than simple concatenations of
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    86
    arguments to the question.
145
claus
parents: 144
diff changeset
    87
claus
parents: 144
diff changeset
    88
    More languages can be added later without any change in the code,
claus
parents: 144
diff changeset
    89
    recompilation or the like. 
claus
parents: 144
diff changeset
    90
    Even by people without access to the source code i.e. which only have the 
claus
parents: 144
diff changeset
    91
    applications binary.
claus
parents: 144
diff changeset
    92
claus
parents: 144
diff changeset
    93
    Also, unsupported languages' strings are simply left unchanged - if you
claus
parents: 144
diff changeset
    94
    write your application in (say) english, and only plan to use it in english,
claus
parents: 144
diff changeset
    95
    no additional work is required (i.e you dont need a resource file then).
claus
parents: 144
diff changeset
    96
    Strings for unknown languages will come in english 
claus
parents: 144
diff changeset
    97
    (which is better than nothing or empty button labels ;-)
claus
parents: 144
diff changeset
    98
claus
parents: 144
diff changeset
    99
    Summary:
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   100
	in subclasses of View and ApplicationModel,
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   101
	instead of writing:
145
claus
parents: 144
diff changeset
   102
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   103
		...
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   104
		b := Button label:'press me'
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   105
		...
145
claus
parents: 144
diff changeset
   106
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   107
	always write:
612
8758d0c9933e documentation
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   108
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   109
		...
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   110
		b := Button label:(resources string:'press me')
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   111
		...
145
claus
parents: 144
diff changeset
   112
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   113
	if your class is not a subclass of one of the above, AND you need
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   114
	resource translations, you wont inherit the resources variable
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   115
	(which is automatically initialized).
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   116
	In this case, you have to ask the ResourcePack class explicitely for
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   117
	a corresponding package:
145
claus
parents: 144
diff changeset
   118
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   119
		ResourcePack for:aClassName
145
claus
parents: 144
diff changeset
   120
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   121
	as an example, see how the Date class gets the national names of
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   122
	week & monthnames.
145
claus
parents: 144
diff changeset
   123
612
8758d0c9933e documentation
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   124
    [author:]
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   125
	Claus Gittinger
145
claus
parents: 144
diff changeset
   126
"
claus
parents: 144
diff changeset
   127
!
claus
parents: 144
diff changeset
   128
claus
parents: 144
diff changeset
   129
examples
claus
parents: 144
diff changeset
   130
"
claus
parents: 144
diff changeset
   131
    normally, resources are found in files named after their classes sourcefile
claus
parents: 144
diff changeset
   132
    For example, the FileBrowsers resources are found in 'FBrowser.rs'.
claus
parents: 144
diff changeset
   133
    For the examples below, we process resources from a constant string;
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   134
	this is NOT representative.
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   135
									[exBegin]
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   136
	|stream res|
145
claus
parents: 144
diff changeset
   137
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   138
	stream := ReadStream on:'
145
claus
parents: 144
diff changeset
   139
foo  ''the translation for foo''
3422
f00c788fa81f Comment only
Stefan Vogel <sv@exept.de>
parents: 3407
diff changeset
   140
#if Language == #de
145
claus
parents: 144
diff changeset
   141
bar  ''die deutsche uebersetzung von bar''
claus
parents: 144
diff changeset
   142
baz  ''baz hat den Wert %1''
claus
parents: 144
diff changeset
   143
#endif
3422
f00c788fa81f Comment only
Stefan Vogel <sv@exept.de>
parents: 3407
diff changeset
   144
#if Language == #fr
145
claus
parents: 144
diff changeset
   145
bar  ''bar en francaise''
claus
parents: 144
diff changeset
   146
baz  ''%1, c''''est baz''
claus
parents: 144
diff changeset
   147
#endif
claus
parents: 144
diff changeset
   148
claus
parents: 144
diff changeset
   149
'.
claus
parents: 144
diff changeset
   150
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   151
	res := ResourcePack new readFromResourceStream:stream in:nil.
145
claus
parents: 144
diff changeset
   152
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   153
	Transcript showCR:'baz is translated to: ' , (res string:'baz' with:'1234').
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   154
	Transcript showCR:'bar is translated to: ' , (res string:'bar').
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   155
	Transcript showCR:'foo is translated to: ' , (res string:'foo').
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   156
	Transcript showCR:'fooBar is translated to: ' , (res string:'fooBar').
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   157
									[exEnd]
145
claus
parents: 144
diff changeset
   158
    set the Language to french:
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   159
									[exBegin]
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   160
	Language := #fr
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   161
									[exEnd]
145
claus
parents: 144
diff changeset
   162
    and repeat the above.
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   163
    back to english:
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   164
									[exBegin]
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   165
	Language := #en 
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   166
									[exEnd]
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   167
    back to german:
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   168
									[exBegin]
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   169
	Language := #de 
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   170
									[exEnd]
46
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
   171
"
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
   172
! !
5
claus
parents: 2
diff changeset
   173
1173
86a212598655 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   174
!ResourcePack class methodsFor:'initialization'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   175
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   176
flushCachedResourcePacks
24
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   177
    "forget all cached resources - needed after a style change"
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   178
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   179
    Packs := nil.
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   180
    self initialize
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   181
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   182
    "
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   183
     ResourcePack flushCachedResourcePacks
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   184
    "
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   185
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   186
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   187
initialize
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   188
    Packs isNil ifTrue:[
4623
81241ac5d815 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
   189
        Packs := WeakArray new:100
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   190
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   191
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   192
    "
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   193
     ResourcePack initialize
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   194
    "
4623
81241ac5d815 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
   195
81241ac5d815 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
   196
    "Modified: / 18-09-2006 / 20:37:38 / cg"
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   197
! !
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   198
1173
86a212598655 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   199
!ResourcePack class methodsFor:'instance creation'!
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   200
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   201
for:aClass
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   202
    "get the full resource definitions for aClass (i.e. with super packs).
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   203
     Also leave the resulting pack in the cache for faster access next time."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   204
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   205
    ^ self for:aClass cached:false
4030
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   206
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   207
    "
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   208
     ResourcePack for:TextView     
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   209
     ResourcePack for:CodeView
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   210
     ResourcePack for:Workspace  
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   211
     ResourcePack for:View      
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   212
     ResourcePack for:ErrorLogger 
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   213
     ResourcePack for:NewLauncher 
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   214
     Workspace classResources
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   215
    "
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   216
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   217
    "Modified: / 18-09-2006 / 19:02:57 / cg"
4030
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   218
!
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   219
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   220
for:aClass cached:cached
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   221
    "get the full resource definitions for aClass (i.e. with super packs).
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   222
     Also leave the resulting pack in the cache for faster access next time."
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   223
3980
443283639aed resourceDirectory asked from class
Claus Gittinger <cg@exept.de>
parents: 3979
diff changeset
   224
    |nm pack rsrcDir baseName|
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   225
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   226
    nm := aClass resourcePackName.
4030
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   227
    cached ifTrue:[
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   228
        pack := self searchCacheFor:nm.
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   229
        pack notNil ifTrue:[^ pack].
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   230
    ].
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   231
3049
d5f2b3f66e37 load resources from package directory, if present
Claus Gittinger <cg@exept.de>
parents: 3047
diff changeset
   232
    baseName := (Smalltalk fileNameForClass:nm) , '.rs'.
3980
443283639aed resourceDirectory asked from class
Claus Gittinger <cg@exept.de>
parents: 3979
diff changeset
   233
    rsrcDir := aClass resourceDirectory.
2970
928387584c9c for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents: 2608
diff changeset
   234
4148
0a9c11fc8844 *** empty log message ***
werner
parents: 4094
diff changeset
   235
"/ CHECK this
0a9c11fc8844 *** empty log message ***
werner
parents: 4094
diff changeset
   236
"/    (rsrcDir notNil and:[rsrcDir suffix = 'rs']) ifTrue:[
0a9c11fc8844 *** empty log message ***
werner
parents: 4094
diff changeset
   237
"/        baseName := (Smalltalk fileNameForClass: rsrcDir tail asFilename withoutSuffix pathName),'.rs'. 
0a9c11fc8844 *** empty log message ***
werner
parents: 4094
diff changeset
   238
"/        rsrcDir := rsrcDir head asFilename.
0a9c11fc8844 *** empty log message ***
werner
parents: 4094
diff changeset
   239
"/    ].
0a9c11fc8844 *** empty log message ***
werner
parents: 4094
diff changeset
   240
4643
2f1b2d98d0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   241
    rsrcDir notNil ifTrue:[ 
2f1b2d98d0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   242
        pack := self new.
2f1b2d98d0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   243
        rsrcDir exists ifTrue:[ 
2f1b2d98d0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   244
            (rsrcDir construct:baseName) exists ifTrue:[
2f1b2d98d0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   245
                pack := self fromFile:baseName directory:(rsrcDir name) cached:true.
2f1b2d98d0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   246
            ].
2f1b2d98d0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   247
        ]
2970
928387584c9c for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents: 2608
diff changeset
   248
    ] ifFalse:[
4643
2f1b2d98d0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   249
        pack := self fromFile:baseName directory:'resources' cached:true.
2970
928387584c9c for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents: 2608
diff changeset
   250
    ].
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   251
    aClass superclass notNil ifTrue:[
3808
b2e08ce8e918 unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   252
        pack superPack:(self for:(aClass superclass)).
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   253
    ].
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   254
    pack packsClassOrFileName:nm.
4030
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   255
    cached ifTrue:[
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   256
        self addToCache:pack.
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   257
    ].
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   258
    pack projectPack:(self forPackage:(aClass resourcePackage) cached:true).
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   259
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   260
    ^ pack
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   261
4656
e7746815918b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4643
diff changeset
   262
    "                   
e7746815918b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4643
diff changeset
   263
     ResourcePack forPackage:'bosch:dapasx' cached:true
e7746815918b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4643
diff changeset
   264
3046
a8ba36b04c26 search in package directory
Claus Gittinger <cg@exept.de>
parents: 3003
diff changeset
   265
     ResourcePack for:TextView     
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   266
     ResourcePack for:CodeView
3046
a8ba36b04c26 search in package directory
Claus Gittinger <cg@exept.de>
parents: 3003
diff changeset
   267
     ResourcePack for:Workspace  
3049
d5f2b3f66e37 load resources from package directory, if present
Claus Gittinger <cg@exept.de>
parents: 3047
diff changeset
   268
     ResourcePack for:View      
2970
928387584c9c for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents: 2608
diff changeset
   269
     ResourcePack for:ErrorLogger 
3101
38cc69894380 fix to avoid loosing the directory with #includes
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   270
     ResourcePack for:NewLauncher 
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   271
     Workspace classResources
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   272
    "
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   273
4656
e7746815918b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4643
diff changeset
   274
    "Modified: / 19-10-2006 / 23:10:02 / cg"
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   275
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   276
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   277
forPackage:package 
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   278
    "get the full resource definitions given a package id (such as stx:libbasic').
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   279
     Also leave the resulting pack in the cache for faster access next time."
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   280
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   281
    ^ self forPackage:package cached:true
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   282
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   283
    "
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   284
     ResourcePack forPackage:'stx:libbasic'   
4618
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   285
     ResourcePack forPackage:'stx:libtool'   
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   286
    "
4618
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   287
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   288
    "Modified: / 18-09-2006 / 18:45:31 / cg"
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   289
!
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   290
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   291
forPackage:package cached:cached
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   292
    "get the full resource definitions given a package id (such as stx:libbasic').
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   293
     Also optionally leave the resulting pack in the cache for faster access next time."
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   294
4673
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   295
    ^ self forPackage:package resourceFileName:'resources.rs' cached:cached
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   296
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   297
    "
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   298
     ResourcePack forPackage:'stx:libbasic' cached:false     
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   299
    "
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   300
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   301
    "Modified: / 19-10-2006 / 23:18:28 / cg"
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   302
!
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   303
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   304
forPackage:package resourceFileName:resourceFileName cached:cached
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   305
    "get the full resource definitions given a package id (such as stx:libbasic').
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   306
     Also optionally leave the resulting pack in the cache for faster access next time."
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   307
4428
599139d322df resource file search
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
   308
    |fullName pack rsrcDir file|
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   309
4673
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   310
    fullName := package , '/resources/',resourceFileName.
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   311
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   312
    cached ifTrue:[
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   313
        pack := self searchCacheFor:fullName.
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   314
        pack notNil ifTrue:[^ pack].
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   315
    ].
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   316
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   317
    rsrcDir := Smalltalk projectDirectoryForPackage:package.
4428
599139d322df resource file search
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
   318
    rsrcDir isNil ifTrue:[
4673
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   319
        file := Smalltalk getResourceFileName:resourceFileName forPackage:package.
4428
599139d322df resource file search
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
   320
        file isNil ifTrue:[^ nil].
599139d322df resource file search
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
   321
        rsrcDir := file asFilename directory.
599139d322df resource file search
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
   322
    ] ifFalse:[
599139d322df resource file search
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
   323
        rsrcDir := rsrcDir asFilename construct:'resources'.
599139d322df resource file search
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
   324
        rsrcDir exists ifFalse:[^ nil].
599139d322df resource file search
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
   325
    ].
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   326
4673
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   327
    pack := self fromFile:resourceFileName directory:rsrcDir cached:cached.
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   328
    pack packsClassOrFileName:fullName.
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   329
    ^ pack
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   330
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   331
    "
4673
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   332
     ResourcePack forPackage:'stx:libbasic' resourceFileName:'resources.rs' cached:false     
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   333
    "
4656
e7746815918b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4643
diff changeset
   334
e7746815918b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4643
diff changeset
   335
    "Modified: / 19-10-2006 / 23:18:28 / cg"
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   336
!
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   337
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   338
fromFile:aFileName
4611
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   339
    "get the resource definitions from a file in the default directory."
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   340
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   341
    ^ self fromFile:aFileName directory:'resources'
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   342
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   343
    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   344
     ResourcePack fromFile:'SBrowser.rs'
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   345
     ResourcePack fromFile:'FBrowser.rs'
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   346
     ResourcePack fromFile:'Smalltalk.rs'
3678
d180d63dc7ca #fromFile: - accept a Filename
Stefan Vogel <sv@exept.de>
parents: 3567
diff changeset
   347
     ResourcePack fromFile:'Smalltalk.rs' asFilename
3983
5c4422ca05c8 encoding: allow symbol
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   348
     ResourcePack fromFile:'../../libtool/resources/AboutBox_ru.rs' asFilename
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   349
    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   350
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   351
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   352
fromFile:aFileName directory:dirName
4611
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   353
    "get the resource definitions from a file in a directory."
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   354
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   355
    ^ self fromFile:aFileName directory:dirName cached:false
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   356
!
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   357
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   358
fromFile:aFileName directory:dirName cached:cached
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   359
    "get the resource definitions from a file in a directory.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   360
     Uncached low-level entry."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   361
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   362
    |newPack|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   363
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   364
    newPack := self new.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   365
    newPack readFromFile:aFileName directory:dirName.
4611
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   366
    cached ifTrue:[
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   367
        self addToCache:newPack.
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   368
    ].
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   369
    ^ newPack
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   370
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   371
1173
86a212598655 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   372
!ResourcePack class methodsFor:'private'!
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   373
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   374
addToCache:aPack
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   375
    |idx|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   376
4084
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   377
    Packs isNil ifTrue:[
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   378
        self initialize.
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   379
    ].
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   380
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   381
    idx := Packs identityIndexOf:nil.
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   382
    idx == 0 ifTrue:[
4084
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   383
        idx := Packs identityIndexOf:0
1078
f7b6f15899ab changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents: 1042
diff changeset
   384
    ].
f7b6f15899ab changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents: 1042
diff changeset
   385
    idx == 0 ifTrue:[
4084
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   386
        "
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   387
         throw away oldest
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   388
        "
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   389
        idx := Packs size.
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   390
        Packs replaceFrom:1 to:idx-1 with:Packs startingAt:2.
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   391
    ].
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   392
    aPack at:'__language__' put:(Smalltalk language,'_',Smalltalk languageTerritory).
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   393
    Packs at:idx put:aPack.
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   394
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   395
    "Modified: / 18-09-2006 / 19:12:12 / cg"
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   396
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   397
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   398
searchCacheFor:aClassOrFileName
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   399
    |sz "{ Class: SmallInteger }" lang|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   400
24
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   401
    Packs isNil ifTrue:[
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   402
        self initialize.
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   403
        ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   404
    ].
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   405
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   406
    lang := (Smalltalk language,'_',Smalltalk languageTerritory).
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   407
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   408
    sz := Packs size.
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   409
    1 to:sz do:[:idx |
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   410
        |aPack|
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   411
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   412
        aPack := Packs at:idx.
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   413
        (aPack notNil and:[aPack ~~ 0]) ifTrue:[
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   414
            (aPack at:'__language__' ifAbsent:nil) = lang ifTrue:[
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   415
                aClassOrFileName = aPack packsClassOrFileName ifTrue:[
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   416
                    "
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   417
                     bring to front for LRU
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   418
                    "
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   419
                    idx ~~ 1 ifTrue:[
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   420
                        Packs replaceFrom:2 to:idx with:Packs startingAt:1.
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   421
                        Packs at:1 put:aPack.
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   422
                    ].
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   423
                    ^ aPack
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   424
                ]
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   425
            ]
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   426
        ]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   427
    ].
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   428
    ^ nil
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   429
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   430
    "
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   431
     ResourcePack searchCacheFor:'TextView' 
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   432
    "
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   433
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   434
    "Modified: / 18-09-2006 / 19:13:13 / cg"
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   435
! !
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   436
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   437
!ResourcePack class methodsFor:'utilities'!
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   438
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   439
extractEncodingFromLine:lineString
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   440
    |rest encoding|
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   441
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   442
    (lineString startsWith:'encoding') ifFalse:[^ nil].
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   443
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   444
    rest := lineString copyFrom:9.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   445
    rest := rest withoutSeparators.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   446
    (rest startsWith:'#') ifTrue:[
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   447
        rest := rest copyFrom:2.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   448
    ].
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   449
    (rest startsWith:'''') ifTrue:[
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   450
        rest := rest copyFrom:2.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   451
        (rest endsWith:'''') ifTrue:[
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   452
            rest := rest copyWithoutLast:1.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   453
        ].
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   454
    ].
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   455
    encoding := rest asSymbol.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   456
    ^ encoding.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   457
!
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   458
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   459
processResourceLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError for:aResourcePack
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   460
    "process a single valid line (i.e. #ifdef & #include has already been processed)"
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   461
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   462
    self
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   463
        processResourceLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError for:aResourcePack
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   464
        keepUselessTranslations:false.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   465
!
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   466
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   467
processResourceLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError for:aResourcePack keepUselessTranslations:keepUselessTranslations
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   468
    "process a single valid line (i.e. #ifdef & #include has already been processed)"
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   469
4531
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   470
    |name decodedLine lineStream idx rest macroName value 
4670
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   471
     conditional hasError decoder oldValue ignoreTranslation indirect|
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   472
4531
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   473
    encodingSymbolOrEncoder notNil ifTrue:[
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   474
        encodingSymbolOrEncoder isSymbol ifTrue:[
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   475
            decoder := CharacterEncoder encoderFor:encodingSymbolOrEncoder ifAbsent:nil.
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   476
            decoder isNil ifTrue:[ decoder := CharacterEncoder::NullEncoder ].
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   477
        ] ifFalse:[
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   478
            decoder := encodingSymbolOrEncoder
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   479
        ].
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   480
    ].
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   481
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   482
    decoder notNil ifTrue:[
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   483
        decodedLine := decoder decodeString:lineString.
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   484
        lineStream := ReadStream on:decodedLine.
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   485
    ] ifFalse:[
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   486
        lineStream := ReadStream on:lineString.
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   487
    ].
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   488
    lineStream signalAtEnd:false.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   489
    lineStream skipSeparators.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   490
    lineStream peek == $# ifTrue:[
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   491
        name := Array 
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   492
                    readFrom:lineStream 
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   493
                    onError:[  
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   494
                                printError value:('invalid line <' , lineString , '>').
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   495
                                nil
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   496
                            ].
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   497
    ] ifFalse:[
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   498
        lineStream peek == $' ifTrue:[
4534
d71ca6ac7cbe handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents: 4531
diff changeset
   499
            name := UnicodeString 
d71ca6ac7cbe handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents: 4531
diff changeset
   500
                        readSmalltalkStringFrom:lineStream 
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   501
                        onError:[
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   502
                                    printError value:('invalid line <' , lineString , '>').
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   503
                                    nil
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   504
                                ].
4534
d71ca6ac7cbe handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents: 4531
diff changeset
   505
            name := name asSingleByteStringIfPossible.
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   506
        ] ifFalse:[
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   507
            name := lineStream upToSeparator.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   508
        ].
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   509
    ].
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   510
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   511
    name isNil ifTrue:[^ self ].
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   512
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   513
    ignoreTranslation := false.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   514
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   515
    hasError := false.
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   516
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   517
    lineStream skipSeparators.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   518
    idx := lineStream position1Based + 1.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   519
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   520
    lineStream peek == $< ifTrue:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   521
        "
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   522
         skip <type> if present
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   523
        "
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   524
        lineStream skipThrough:$>.
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   525
        lineStream skipSeparators.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   526
        idx := lineStream position1Based + 1.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   527
    ].
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   528
4670
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   529
    conditional := indirect := false.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   530
    lineStream peek == $? ifTrue:[
4670
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   531
        conditional := true.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   532
        lineStream next.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   533
        lineStream skipSeparators.
4670
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   534
    ].
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   535
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   536
    lineStream peek == $@ ifTrue:[
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   537
        indirect := true.
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   538
        lineStream next.
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   539
        lineStream skipSeparators.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   540
    ].
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   541
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   542
    lineStream peek == $= ifTrue:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   543
        lineStream next.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   544
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   545
        macroName := lineStream nextAlphaNumericWord.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   546
        [lineStream peek == $.] whileTrue:[
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   547
            lineStream next.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   548
            lineStream peek notNil ifTrue:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   549
                macroName := macroName , '.' , (lineStream nextAlphaNumericWord)
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   550
            ]
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   551
        ].
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   552
        rest := lineStream upToEnd.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   553
        value := aResourcePack at:macroName ifAbsent:nil.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   554
        (value isNil) ifTrue:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   555
            hasError := true.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   556
            printError value:('bad (nil-valued) macro: ' , macroName).
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   557
        ].
4678
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   558
"/        value isBlock ifTrue:[
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   559
"/            value := value value
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   560
"/        ].
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   561
        rest isBlank ifFalse:[
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   562
            value := Compiler evaluate:('self ' , rest)
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   563
                              receiver:value
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   564
                              notifying:nil
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   565
                              compile:false.
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   566
            (value == #Error) ifTrue:[
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   567
                hasError := true.
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   568
                printError value:('error in: "self ' , rest , '"').
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   569
            ]
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   570
        ]
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   571
    ] ifFalse:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   572
        lineStream peek == $' ifTrue:[
4534
d71ca6ac7cbe handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents: 4531
diff changeset
   573
            value := UnicodeString 
d71ca6ac7cbe handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents: 4531
diff changeset
   574
                        readSmalltalkStringFrom:lineStream 
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   575
                        onError:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   576
                                    printError value:('invalid line <' , lineString , '>').
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   577
                                    nil
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   578
                                ].
4534
d71ca6ac7cbe handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents: 4531
diff changeset
   579
            value := value asSingleByteStringIfPossible.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   580
        ] ifFalse:[
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   581
            rest := lineStream upToEnd.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   582
            value := Compiler evaluate:rest compile:false.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   583
        ].
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   584
        (value == #Error) ifTrue:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   585
            hasError := true.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   586
            printError value:('error in: "' , rest , '"').
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   587
        ] ifFalse:[
4531
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   588
"/            value isString ifTrue:[
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   589
"/                decoder notNil ifTrue:[
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   590
"/                    value := decoder decodeString:value
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   591
"/                ]
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   592
"/            ]
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   593
        ]
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   594
    ].
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   595
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   596
    hasError ifFalse:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   597
        (conditional not
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   598
        or:[(aResourcePack includesKey:name) not]) ifTrue:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   599
            name = value ifTrue:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   600
                keepUselessTranslations ifFalse:[ 
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   601
                    printError value:('useless resource: "' , name , '"').
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   602
                    ignoreTranslation := true 
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   603
                ].
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   604
            ].
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   605
            ignoreTranslation ifFalse:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   606
                oldValue := aResourcePack at:name ifAbsent:nil.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   607
                oldValue notNil ifTrue:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   608
                    oldValue ~= value ifTrue:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   609
                        printError value:('conflicting resource: "' , name , '"').
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   610
                        printError value:('oldValue: ' , oldValue printString).
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   611
                        printError value:('newValue: ' , value printString).
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   612
                    ] ifFalse:[
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   613
                        printError value:('duplicate resource: "' , name , '"').
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   614
                    ].
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   615
                ].
4670
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   616
                indirect ifTrue:[
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   617
                    value := aResourcePack string:value.
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   618
                ].
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   619
                aResourcePack at:name put:value.
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   620
            ]
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   621
        ]
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   622
    ]
4534
d71ca6ac7cbe handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents: 4531
diff changeset
   623
4678
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   624
    "Modified: / 09-11-2006 / 13:17:48 / cg"
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   625
! !
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   626
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   627
!ResourcePack methodsFor:'accessing'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   628
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   629
array:anArray
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   630
    "translate a collection of strings"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   631
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   632
    ^ anArray collect:[:r | self at:r default:r]
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   633
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   634
    "
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   635
     Launcher classResources array:#('file' 'classes') 
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   636
    "
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   637
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   638
    "Modified: / 29.1.1998 / 22:44:22 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   639
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   640
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   641
at:aKey
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   642
    "translate a string"
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   643
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   644
    ^ self at:aKey ifAbsent:aKey
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   645
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   646
48194c26a46c Initial revision
claus
parents:
diff changeset
   647
at:aKey default:default
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   648
    "translate a string"
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   649
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   650
    ^ self at:aKey ifAbsent:default
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   651
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   652
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   653
at:aKey ifAbsent:defaultValue
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   654
    "translate a string; search here, in my projects pack and in my superpack(s)"
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   655
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   656
    |val pack projectPack alreadySearched|
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   657
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   658
    aKey isNil ifTrue:[ ^ defaultValue value ].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   659
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   660
    val := self localAt:aKey.
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   661
    val notNil ifTrue:[^ val].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   662
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   663
    (projectPack := self projectPack) notNil ifTrue:[
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   664
        val := projectPack localAt:aKey.
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   665
        val notNil ifTrue:[^ val].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   666
    ].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   667
    alreadySearched := Set new.
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   668
    projectPack notNil ifTrue:[ alreadySearched add:projectPack ].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   669
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   670
    pack := self superPack.
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   671
    [ pack notNil ] whileTrue:[
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   672
        val := pack localAt:aKey.
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   673
        val notNil ifTrue:[^ val].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   674
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   675
        (projectPack := pack projectPack) notNil ifTrue:[
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   676
            (alreadySearched includes:projectPack) ifFalse:[
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   677
                val := projectPack localAt:aKey.
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   678
                val notNil ifTrue:[^ val].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   679
                alreadySearched add:projectPack.
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   680
            ].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   681
        ].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   682
        pack := pack superPack
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   683
    ].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   684
4618
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   685
    alreadySearched copy do:[:projectPack |
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   686
        |p|
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   687
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   688
        p := projectPack superPack.
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   689
        [p notNil and:[(alreadySearched includes:p) not]] whileTrue:[
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   690
            val := p localAt:aKey.
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   691
            val notNil ifTrue:[^ val].
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   692
            alreadySearched add:p.
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   693
            p := p superPack.
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   694
        ].
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   695
    ].
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   696
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   697
    ^ defaultValue value
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   698
4618
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   699
    "Modified: / 18-09-2006 / 18:50:52 / cg"
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   700
!
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   701
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   702
localAt:aKey
4035
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   703
    "translate a string.
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   704
     Some special 'intelligence' has been added:
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   705
        if no value for aKey is found,
4036
4978ac9fbe27 comment
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   706
          lookup aKey with first character caseChanged and change the results first characters case.
4978ac9fbe27 comment
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   707
          or aKey ends with a ':', then lookup aKey without ':' and append ':' to the result.
4978ac9fbe27 comment
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   708
          or aKey ends with a '=', then lookup aKey without '=' and append '=' to the result.
4037
63eda0e11dca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4036
diff changeset
   709
          or aKey ends with a '.', then lookup aKey without '.' and append '.' to the result.
4796
c17e24be80c1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4678
diff changeset
   710
          or aKey ends with a ',', then lookup aKey without ',' and append ',' to the result.
4036
4978ac9fbe27 comment
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   711
          or aKey ends with a ' ', then lookup aKey without ' '.
4978ac9fbe27 comment
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   712
          or aKey ends with a ' ...', then lookup aKey without ' ...' and append '...' to the result.
4978ac9fbe27 comment
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   713
          or aKey ends with a '...', then lookup aKey without '...' and append '...' to the result.
4978ac9fbe27 comment
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   714
          or aKey includes '&', then lookup aKey without '&'.
4035
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   715
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   716
     This means, that only a single translation is required to provide local translations for
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   717
     things like 
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   718
        'search'
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   719
        'search:'
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   720
        'search...'
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   721
    "
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   722
4017
b0bbac385c4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3986
diff changeset
   723
    |val alternativeKey rest usedKey idx|
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   724
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   725
    val := super at:aKey ifAbsent:nil.
4678
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   726
    val notNil ifTrue:[
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   727
        ^ val value
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   728
    ].
3549
8c924bf310ed lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents: 3484
diff changeset
   729
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   730
    (aKey isString and:[aKey size > 0]) ifTrue:[
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   731
        "/ try with case-first swapped...
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   732
        (aKey first isLetter) ifTrue:[
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   733
            alternativeKey := aKey isUppercaseFirst 
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   734
                                ifTrue:[aKey asLowercaseFirst]
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   735
                                ifFalse:[aKey asUppercaseFirst].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   736
            val := super at:alternativeKey ifAbsent:nil.
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   737
            val notNil ifTrue:[
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   738
                aKey isUppercaseFirst ifTrue:[
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   739
                    ^ val asUppercaseFirst
3979
75850ede052c if no xlation is found, look for string folowed by ':' or '='
Claus Gittinger <cg@exept.de>
parents: 3854
diff changeset
   740
                ].
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   741
                ^ val asLowercaseFirst.                
4028
Claus Gittinger <cg@exept.de>
parents: 4019
diff changeset
   742
            ].
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   743
        ].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   744
4634
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   745
        (aKey endsWith:' ...') ifTrue:[
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   746
            usedKey := aKey copyWithoutLast:4.
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   747
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   748
            val := self localAt:usedKey.        "/ recursion
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   749
            val notNil ifTrue:[^ val , '...'].
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   750
        ].
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   751
        (aKey endsWith:'...') ifTrue:[
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   752
            usedKey := aKey copyWithoutLast:3.
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   753
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   754
            val := self localAt:usedKey.        "/ recursion
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   755
            val notNil ifTrue:[^ val , '...'].
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   756
        ].
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   757
4796
c17e24be80c1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4678
diff changeset
   758
        (':=.?!!,' includes:aKey last) ifTrue:[
4634
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   759
            aKey size > 2 ifTrue:[
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   760
                rest := aKey last.
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   761
                usedKey := aKey copyWithoutLast:1.
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   762
4634
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   763
                val := self localAt:usedKey.        "/ recursion
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   764
                val notNil ifTrue:[^ val , rest].
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   765
            ].
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   766
        ].
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   767
        (':=.?!!' includes:aKey first) ifTrue:[
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   768
            aKey size > 2 ifTrue:[
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   769
                rest := aKey first.
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   770
                usedKey := aKey copyFrom:2.
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   771
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   772
                val := self localAt:usedKey.        "/ recursion
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   773
                val notNil ifTrue:[^ rest asString , val].
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   774
            ].
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   775
        ].
4028
Claus Gittinger <cg@exept.de>
parents: 4019
diff changeset
   776
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   777
        ((aKey startsWith:'(') and:[(aKey endsWith:')')]) ifTrue:[
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   778
            usedKey := aKey copyFrom:2 to:(aKey size - 1).
4028
Claus Gittinger <cg@exept.de>
parents: 4019
diff changeset
   779
4634
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   780
            val := self localAt:usedKey.        "/ recursion
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   781
            val notNil ifTrue:[^ '(' , val , ')'].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   782
        ].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   783
        (aKey endsWith:' ') ifTrue:[
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   784
            usedKey := aKey withoutSeparators.
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   785
4634
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   786
            val := self localAt:usedKey.        "/ recursion
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   787
            val notNil ifTrue:[^ val].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   788
        ].
4017
b0bbac385c4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3986
diff changeset
   789
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   790
        (idx := aKey indexOf:$&) ~~ 0 ifTrue:[
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   791
            (aKey at:idx+1 ifAbsent:nil) ~~ $& ifTrue:[
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   792
                usedKey := (aKey copyTo:idx-1) , (aKey copyFrom:idx+1).
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   793
                val := super at:usedKey ifAbsent:nil.    "/ recursion
4028
Claus Gittinger <cg@exept.de>
parents: 4019
diff changeset
   794
                val notNil ifTrue:[^ val].
Claus Gittinger <cg@exept.de>
parents: 4019
diff changeset
   795
            ].
3979
75850ede052c if no xlation is found, look for string folowed by ':' or '='
Claus Gittinger <cg@exept.de>
parents: 3854
diff changeset
   796
        ].
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   797
    ].
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   798
    ^ nil.
4580
48c0580f3b9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
   799
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   800
    "Created: / 18-09-2006 / 17:33:27 / cg"
4796
c17e24be80c1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4678
diff changeset
   801
    "Modified: / 21-08-2007 / 21:18:12 / cg"
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   802
!
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   803
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   804
name:aKey default:default
2461
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   805
    "translate a string.
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   806
     Obsolete - use #string:default:"
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   807
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   808
    ^ self at:aKey ifAbsent:default
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   809
!
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   810
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   811
string:s
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   812
    "translate (retrieve) a string - if not present, return s"
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   813
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   814
    ^ self at:s ifAbsent:s
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   815
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   816
    "
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   817
     NewLauncher classResources
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   818
	string:'LICENCEFILE' 
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   819
    "
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   820
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   821
2461
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   822
string:s default:defaultString
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   823
    "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
   824
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   825
    ^ self at:s ifAbsent:defaultString
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   826
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   827
    "
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   828
     NewLauncher classResources
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   829
	string:'fooBar' default:'Hello world'  
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   830
    "
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   831
2461
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   832
!
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   833
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   834
string:s default:defaultString with:arg
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   835
    "translate and expand arg"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   836
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   837
    ^ self string:s default:defaultString withArgs:(Array with:arg)
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   838
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   839
    "
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   840
     NewLauncher classResources
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   841
	string:'%1 fooBar' default:'Hello %1' with:'foo' 
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   842
    "
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   843
2461
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   844
!
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   845
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   846
string:s default:defaultString with:arg1 with:arg2
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   847
    "translate and expand args"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   848
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   849
    ^ 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
   850
!
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   851
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   852
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
   853
    "translate and expand args"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   854
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   855
    ^ 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
   856
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   857
    "Created: 9.12.1995 / 19:08:50 / cg"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   858
!
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   859
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   860
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
   861
    "translate and expand args"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   862
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   863
    ^ 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
   864
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   865
    "Created: 9.9.1996 / 18:52:14 / cg"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   866
!
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   867
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   868
string:s default:defaultString withArgs:argArray
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   869
    "translate and expand args"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   870
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   871
    |template|
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   872
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   873
    template := self at:s ifAbsent:defaultString.
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   874
    ^ template expandPlaceholdersWith:argArray
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   875
!
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   876
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   877
string:s with:arg
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   878
    "translate and expand arg"
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   879
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   880
    ^ self string:s withArgs:(Array with:arg)
48194c26a46c Initial revision
claus
parents:
diff changeset
   881
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   882
48194c26a46c Initial revision
claus
parents:
diff changeset
   883
string:s with:arg1 with:arg2
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   884
    "translate and expand args"
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   885
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   886
    ^ self string:s withArgs:(Array with:arg1 with:arg2)
48194c26a46c Initial revision
claus
parents:
diff changeset
   887
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   888
292
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   889
string:s with:arg1 with:arg2 with:arg3
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   890
    "translate and expand args"
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   891
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   892
    ^ 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
   893
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   894
    "Created: 9.12.1995 / 19:08:50 / cg"
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   895
!
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   896
1042
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
   897
string:s with:arg1 with:arg2 with:arg3 with:arg4
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
   898
    "translate and expand args"
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
   899
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
   900
    ^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4)
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
   901
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
   902
    "Created: 9.9.1996 / 18:52:14 / cg"
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
   903
!
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
   904
3184
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
   905
string:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
   906
    "translate and expand args"
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
   907
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
   908
    ^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5)
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
   909
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
   910
!
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
   911
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   912
string:s withArgs:argArray
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   913
    "translate and expand args"
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   914
135
claus
parents: 123
diff changeset
   915
    |template|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   916
2461
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   917
    template := self at:s ifAbsent:s.
135
claus
parents: 123
diff changeset
   918
    ^ template expandPlaceholdersWith:argArray
3823
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   919
!
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   920
4402
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
   921
stringWithCRs:s
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
   922
    "translate (retrieve) a string - if not present, return s"
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
   923
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
   924
    ^ (self string:s) withCRs
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
   925
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
   926
    "
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
   927
     NewLauncher classResources
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
   928
        stringWithCRs:'LICENCEFILE'  
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
   929
    "
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
   930
!
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
   931
3823
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   932
stringWithCRs:s with:arg
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   933
    "translate, replace \'s with CRs and finally expand arg.
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   934
     CR-replacement is donw before args are inserted 
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   935
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   936
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   937
    ^ self stringWithCRs:s withArgs:(Array with:arg)
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   938
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   939
    "Modified: / 21.3.2003 / 14:22:09 / cg"
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   940
!
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   941
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   942
stringWithCRs:s with:arg1 with:arg2
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   943
    "translate, replace \'s with CRs and finally expand args.
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   944
     CR-replacement is donw before args are inserted 
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   945
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   946
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   947
    ^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2)
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   948
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   949
    "Modified: / 21.3.2003 / 14:22:06 / cg"
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   950
!
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   951
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   952
stringWithCRs:s with:arg1 with:arg2 with:arg3
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   953
    "translate, replace \'s with CRs and finally expand args.
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   954
     CR-replacement is donw before args are inserted 
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   955
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   956
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   957
    ^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3)
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   958
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   959
    "Created: 9.12.1995 / 19:08:50 / cg"
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   960
!
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   961
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   962
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   963
    "translate, replace \'s with CRs and finally expand args.
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   964
     CR-replacement is donw before args are inserted 
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   965
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   966
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   967
    ^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4)
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   968
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   969
    "Modified: / 21.3.2003 / 14:21:48 / cg"
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   970
!
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   971
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   972
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   973
    "translate, replace \'s with CRs and finally expand args.
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   974
     CR-replacement is donw before args are inserted 
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   975
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   976
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   977
    ^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5)
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   978
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   979
    "Modified: / 21.3.2003 / 14:21:55 / cg"
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   980
!
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   981
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   982
stringWithCRs:s withArgs:argArray
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   983
    "translate, replace \'s with CRs and finally expand args.
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   984
     CR-replacement is donw before args are inserted 
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   985
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   986
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   987
    |template|
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   988
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   989
    template := self at:s ifAbsent:s.
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   990
    ^ template withCRs expandPlaceholdersWith:argArray
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   991
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
   992
    "Modified: / 21.3.2003 / 14:21:59 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   993
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   994
3317
fbad8f950059 Spelling
Stefan Vogel <sv@exept.de>
parents: 3263
diff changeset
   995
!ResourcePack methodsFor:'accessing-internals'!
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   996
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   997
name:aKey
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   998
    "translate a string"
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   999
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1000
    ^ self at:aKey ifAbsent:aKey
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1001
!
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1002
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1003
packsClassName
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1004
    ^ packsClassName
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1005
!
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1006
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1007
packsClassName:aString
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1008
    packsClassName := aString
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1009
!
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1010
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1011
packsClassOrFileName
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1012
    ^ packsClassName
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1013
!
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1014
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1015
packsClassOrFileName:aString
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1016
    packsClassName := aString
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1017
!
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1018
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1019
projectPack
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1020
    ^ projectPack
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1021
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1022
    "Created: / 18-09-2006 / 17:38:07 / cg"
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1023
!
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1024
4085
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  1025
projectPack:anotherResourcePack
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  1026
    projectPack := anotherResourcePack
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  1027
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  1028
    "Created: / 29.1.1998 / 22:43:09 / cg"
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  1029
!
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  1030
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1031
superPack
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1032
    ^ superPack
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1033
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1034
    "Created: / 18-09-2006 / 17:38:12 / cg"
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1035
!
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1036
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1037
superPack:anotherResourcePack
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1038
    superPack := anotherResourcePack
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1039
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1040
    "Created: / 29.1.1998 / 22:43:09 / cg"
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1041
! !
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1042
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1043
!ResourcePack methodsFor:'file reading'!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1044
684
4c7efce60043 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
  1045
fileReadFailed
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1046
    "return true, if the pack does not really contain
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1047
     valid translations, since the fileRead failed.
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1048
     However, all inherited translations are still available
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1049
     through the receiver"
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1050
687
d2cf3cd18f65 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 686
diff changeset
  1051
    ^ fileReadFailed ~~ false
684
4c7efce60043 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
  1052
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1053
    "Created: / 14.5.1996 / 10:19:26 / cg"
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1054
    "Modified: / 29.1.1998 / 22:46:38 / cg"
684
4c7efce60043 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
  1055
!
4c7efce60043 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
  1056
1894
9982e96dff75 better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
  1057
nonexistingFileRead
9982e96dff75 better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
  1058
    "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
  1059
     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
  1060
     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
  1061
9982e96dff75 better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
  1062
    ^ nil
9982e96dff75 better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
  1063
9982e96dff75 better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
  1064
    "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
  1065
!
9982e96dff75 better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
  1066
4332
767357a4294d allow array as key
Claus Gittinger <cg@exept.de>
parents: 4198
diff changeset
  1067
processLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError
145
claus
parents: 144
diff changeset
  1068
    "process a single valid line (i.e. #ifdef & #include has already been processed)"
claus
parents: 144
diff changeset
  1069
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
  1070
    self class
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
  1071
        processResourceLine:lineString 
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
  1072
        encoding:encodingSymbolOrEncoder 
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
  1073
        file:fileName 
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
  1074
        printErrorWith:printError 
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
  1075
        for:self
144
claus
parents: 135
diff changeset
  1076
!
claus
parents: 135
diff changeset
  1077
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1078
readFromFile:fileName directory:dirName
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1079
    "read definitions from a file in a directory"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1080
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1081
    |inStream ok|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1082
686
152d8437af35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 685
diff changeset
  1083
    fileReadFailed := false.
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1084
    dirName = 'resources' ifTrue:[
3769
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1085
        inStream := Smalltalk resourceFileStreamFor:fileName
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1086
    ] ifFalse:[
3769
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1087
        inStream := Smalltalk 
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1088
                        systemFileStreamFor:(dirName 
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1089
                                                isNil ifTrue:[fileName]
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1090
                                                ifFalse:[dirName asFilename construct:fileName]).
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1091
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1092
    inStream isNil ifTrue:[
3769
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1093
        "
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1094
         an empty pack
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1095
        "
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1096
        ^ self nonexistingFileRead
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1097
    ].
2996
59278dabe9a6 catch errors when reading #if
Stefan Vogel <sv@exept.de>
parents: 2971
diff changeset
  1098
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1099
    ok := self readFromResourceStream:inStream in:(inStream pathName asFilename directoryName).
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1100
    inStream close.
686
152d8437af35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 685
diff changeset
  1101
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1102
    ok ifFalse:[
3769
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1103
        fileReadFailed := true.
684
4c7efce60043 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
  1104
3769
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1105
        ('ResourcePack [warning]: ''' , inStream pathName , ''' contains error(s) - data may be incomplete.') errorPrintCR.
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1106
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1107
4656
e7746815918b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4643
diff changeset
  1108
    "Modified: / 19-10-2006 / 22:46:48 / cg"
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1109
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1110
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
  1111
readFromResourceStream:inStream in:dirName
145
claus
parents: 144
diff changeset
  1112
    "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
  1113
     specify where #include files are searched for.
0f942dafc85a gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
  1114
     Return true, if the style sheet could be read without errors, false otherwise."
145
claus
parents: 144
diff changeset
  1115
4058
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1116
    |lineString l lineNumber rest value ifLevel skipping first ok encoding decoder pack errorHandler 
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1117
     printError fileName|
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1118
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1119
    fileName := (inStream isFileStream 
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1120
                    ifTrue:[inStream pathName asFilename baseName]
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1121
                    ifFalse:['---']).
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1122
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1123
    printError := [:message |
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1124
                    'ResourcePack [warning]: ' errorPrint.
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1125
                    message errorPrint.
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1126
                    ' in file:' errorPrint.
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1127
                    fileName errorPrint.
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1128
                    ' line: ' errorPrint.
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1129
                    lineNumber errorPrintCR
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1130
                  ].
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1131
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1132
    printError := [:message | ].
462
423f8426fefc added #encoding directive (I am lazy)
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
  1133
423f8426fefc added #encoding directive (I am lazy)
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
  1134
    encoding := nil.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1135
210
0f942dafc85a gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
  1136
    ok := true.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1137
    ifLevel := 0.
48194c26a46c Initial revision
claus
parents:
diff changeset
  1138
    skipping := false.
4058
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1139
    lineNumber := 0.
3567
f85c170f14e8 allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  1140
f85c170f14e8 allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  1141
    errorHandler := [:ex | 
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1142
                        |con|
4534
d71ca6ac7cbe handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents: 4531
diff changeset
  1143
self halt.
3854
4547dd93dbfd #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1144
                        ('ResourcePack [warning]: ''' , ex description , '''') errorPrintCR.
4058
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1145
                        ('ResourcePack [info]: file: ' , inStream pathName printString , ' line: ' , lineNumber printString , ': ''' , lineString , '''') errorPrintCR.
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1146
                        con := ex suspendedContext.
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1147
                        ('ResourcePack [info]: in: ' , con fullPrintString) errorPrintCR.
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1148
                        con := con sender.
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1149
                        ('ResourcePack [info]:   : ' , con fullPrintString) errorPrintCR.
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1150
                        con := con sender.
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1151
                        ('ResourcePack [info]:   : ' , con fullPrintString) errorPrintCR.
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1152
                        value := nil.
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1153
                        ok := false.
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1154
                    ].
3567
f85c170f14e8 allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  1155
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1156
    [inStream atEnd] whileFalse:[
4058
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1157
        lineString := inStream nextLine. lineNumber := lineNumber + 1.
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1158
        [lineString notNil and:[lineString endsWith:$\]] whileTrue:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1159
            lineString := lineString copyWithoutLast:1.
4058
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1160
            l := inStream nextLine. lineNumber := lineNumber + 1.
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1161
            l notNil ifTrue:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1162
                lineString := lineString , l.
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1163
            ].
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1164
        ].
177
claus
parents: 158
diff changeset
  1165
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1166
        (lineString size > 0) ifTrue:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1167
            first := lineString at:1.
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1168
            "/
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1169
            "/ for your convenience: treat ; AND "/ as comment-line
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1170
            "/
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1171
            ((first == $;) or:[lineString startsWith:'"/']) ifFalse:[
4332
767357a4294d allow array as key
Claus Gittinger <cg@exept.de>
parents: 4198
diff changeset
  1172
                ((first == $#) and:[(lineString startsWith:'#(') not]) ifTrue:[
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1173
                    "/ a directive
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1174
                    lineString := (lineString copyFrom:2) withoutSpaces.
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
  1175
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1176
                    (lineString startsWith:'if') ifTrue:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1177
                        skipping ifFalse:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1178
                            rest := lineString copyFrom:3.
4835
1f64020798d9 changed #readFromResourceStream:in:
Stefan Vogel <sv@exept.de>
parents: 4796
diff changeset
  1179
                            Error, UserInformation
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1180
                                handle:errorHandler 
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1181
                                do:[
4835
1f64020798d9 changed #readFromResourceStream:in:
Stefan Vogel <sv@exept.de>
parents: 4796
diff changeset
  1182
                                    value := Compiler evaluate:rest compile:false
1f64020798d9 changed #readFromResourceStream:in:
Stefan Vogel <sv@exept.de>
parents: 4796
diff changeset
  1183
                                ].
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1184
                            (value == #Error) ifTrue:[
4058
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1185
                                printError value:('error in resource:' , lineString).
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1186
                            ].
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1187
                            (value == false) ifTrue:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1188
                                skipping := true
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1189
                            ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1190
                        ].
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1191
                        ifLevel := ifLevel + 1
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1192
                    ] ifFalse:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1193
                        (lineString startsWith:'endif') ifTrue:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1194
                            ifLevel := ifLevel - 1.
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1195
                            ifLevel == 0 ifTrue:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1196
                                skipping := false
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1197
                            ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1198
                        ] ifFalse:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1199
                            (lineString startsWith:'else') ifTrue:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1200
                                skipping := skipping not
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1201
                            ] ifFalse:[
4618
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1202
                                (lineString startsWith:'superpack') ifTrue:[
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1203
                                    rest := lineString copyFrom:('superpack' size + 1).
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1204
                                    value := Compiler evaluate:rest compile:false.
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1205
                                    (value isKindOf:ResourcePack) ifTrue:[
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1206
                                        superPack := value
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1207
                                    ]
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1208
                                ] ifFalse:[
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1209
                                    skipping ifFalse:[
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1210
                                        (lineString startsWith:'include') ifTrue:[
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1211
                                            (lineString startsWith:'includeResourcesFor') ifTrue:[
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1212
                                                "/ include those resources ...
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1213
                                                rest := lineString copyFrom:('includeResourcesFor' size + 1).
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1214
                                                value := Compiler evaluate:rest compile:false.
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1215
                                                value isBehavior ifTrue:[
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1216
                                                    pack := self class for:value.
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1217
                                                    pack notNil ifTrue:[
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1218
                                                        self addAll:pack.
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1219
                                                    ]
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1220
                                                ]
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1221
                                            ] ifFalse:[
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1222
                                                rest := lineString copyFrom:('include' size + 1).
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1223
                                                value := Compiler evaluate:rest compile:false.
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1224
                                                value isString ifFalse:[
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1225
                                                    printError value:('bad include filename: ' , value printString, ' "',lineString,'"').
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1226
                                                ] ifTrue:[
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1227
                                                    self readFromFile:value directory:dirName
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1228
                                                ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1229
                                            ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1230
                                        ] ifFalse:[
4618
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1231
                                            (lineString startsWith:'encoding') ifTrue:[
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
  1232
decoder notNil ifTrue:[self halt:'oops - encoding change in file'].
4618
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1233
                                                encoding := self class extractEncodingFromLine:lineString.
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
  1234
                                                decoder := CharacterEncoder encoderFor:encoding ifAbsent:nil.
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1235
                                            ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1236
                                        ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1237
                                    ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1238
                                ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1239
                            ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1240
                        ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1241
                    ].
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1242
                ] ifFalse:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1243
                    skipping ifFalse:[
4835
1f64020798d9 changed #readFromResourceStream:in:
Stefan Vogel <sv@exept.de>
parents: 4796
diff changeset
  1244
                        Error, UserInformation
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1245
                            handle:errorHandler 
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1246
                            do:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1247
                                (lineString at:1) == $!! ifTrue:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1248
                                    "/ evaluate the rest
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1249
                                    Compiler evaluate:(lineString copyFrom:2)
4332
767357a4294d allow array as key
Claus Gittinger <cg@exept.de>
parents: 4198
diff changeset
  1250
                                                      receiver:self
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1251
                                                      notifying:nil
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1252
                                                      compile:false.
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1253
                                ] ifFalse:[
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1254
                                    "/ process as resource
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1255
                                    self 
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1256
                                        processLine:lineString 
4017
b0bbac385c4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3986
diff changeset
  1257
                                        encoding:decoder 
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1258
                                        file:(inStream isFileStream 
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1259
                                                ifTrue:[inStream pathName]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1260
                                                ifFalse:['---'])
4058
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1261
                                        printErrorWith:printError
3817
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1262
                                ]]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1263
                    ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1264
                ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1265
            ]
34deab81bfe2 Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3808
diff changeset
  1266
        ]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1267
    ].
210
0f942dafc85a gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
  1268
    ^ ok
177
claus
parents: 158
diff changeset
  1269
4534
d71ca6ac7cbe handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents: 4531
diff changeset
  1270
    "Modified: / 31-08-1995 / 02:33:45 / claus"
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
  1271
    "Modified: / 18-09-2006 / 20:35:37 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1272
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
  1273
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1274
!ResourcePack methodsFor:'printing & storing'!
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1275
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1276
displayString
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1277
    ^ String 
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1278
        streamContents:
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1279
            [:s | 
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1280
                s nextPutAll:'ResourcePack for: '.
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1281
                packsClassName printOn:s
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1282
            ]
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1283
! !
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1284
1173
86a212598655 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
  1285
!ResourcePack class methodsFor:'documentation'!
251
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
  1286
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
  1287
version
4835
1f64020798d9 changed #readFromResourceStream:in:
Stefan Vogel <sv@exept.de>
parents: 4796
diff changeset
  1288
    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.124 2007-11-02 18:01:48 stefan Exp $'
251
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
  1289
! !
3769
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1290
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1291
ResourcePack initialize!