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