Tools__InternationalLanguageTranslationEditor.st
author Claus Gittinger <cg@exept.de>
Mon, 15 May 2006 15:49:52 +0200
changeset 2048 dcec4e818069
parent 2047 5f9b26862c57
child 2049 d10762e5d924
permissions -rw-r--r--
*** empty log message ***
cg@2015
     1
"{ Package: 'stx:libtool2' }"
cg@2015
     2
cg@2015
     3
"{ NameSpace: Tools }"
cg@2015
     4
cg@2015
     5
ApplicationModel subclass:#InternationalLanguageTranslationEditor
cg@2015
     6
	instanceVariableNames:'languagesList keyStringsToLanguageMappings languageTextHolder
cg@2015
     7
		originalTextHolder modified shownLanguages selectedKeyRow
cg@2015
     8
		showMissingTranslationsOnly
cg@2015
     9
		keyStringAndLanguageSelectionTableColumnDescriptionHolder
cg@2015
    10
		languageShownHolders dataSetView lastExtractedClass
cg@2015
    11
		lastExtractedApplicationClass stopApplicationIconVisibleHolder
cg@2015
    12
		monitoredApplication originalTextModifiedHolder
cg@2048
    13
		languageTextModifiedHolder languageTextAcceptHolder
cg@2048
    14
		inSingleFileMode lastExtractedProject lastLanguage
cg@2048
    15
		lastSelectedKey'
cg@2032
    16
	classVariableNames:'LastExtractedClass LastExtractedApplicationClass
cg@2032
    17
		LastExtractedProject'
cg@2015
    18
	poolDictionaries:''
cg@2015
    19
	category:'Interface-UIPainter'
cg@2015
    20
!
cg@2015
    21
cg@2015
    22
Object subclass:#AccessCollectingPseudoResourcePack
cg@2015
    23
	instanceVariableNames:'collectedKeys realResourcePack'
cg@2015
    24
	classVariableNames:''
cg@2015
    25
	poolDictionaries:''
cg@2015
    26
	privateIn:InternationalLanguageTranslationEditor
cg@2015
    27
!
cg@2015
    28
cg@2015
    29
Collection subclass:#KeyStringsToLanguageMappings
cg@2032
    30
	instanceVariableNames:'keys keyInfo perLanguageInfo perLanguageMappings languageMappings
cg@2032
    31
		languages'
cg@2015
    32
	classVariableNames:''
cg@2015
    33
	poolDictionaries:''
cg@2015
    34
	privateIn:InternationalLanguageTranslationEditor
cg@2015
    35
!
cg@2015
    36
cg@2015
    37
Object subclass:#LanguageMappingRow
cg@2015
    38
	instanceVariableNames:'key mappings'
cg@2015
    39
	classVariableNames:''
cg@2015
    40
	poolDictionaries:''
cg@2015
    41
	privateIn:InternationalLanguageTranslationEditor
cg@2015
    42
!
cg@2015
    43
cg@2015
    44
Visitor subclass:#UISpecVisitor
cg@2015
    45
	instanceVariableNames:'translatedLabels'
cg@2015
    46
	classVariableNames:''
cg@2015
    47
	poolDictionaries:''
cg@2015
    48
	privateIn:InternationalLanguageTranslationEditor
cg@2015
    49
!
cg@2015
    50
cg@2015
    51
!InternationalLanguageTranslationEditor class methodsFor:'documentation'!
cg@2015
    52
cg@2015
    53
documentation
cg@2015
    54
"
cg@2015
    55
    documentation to be added.
cg@2015
    56
cg@2015
    57
    [author:]
cg@2015
    58
        cg (cg@FUSI)
cg@2015
    59
cg@2015
    60
    [instance variables:]
cg@2015
    61
cg@2015
    62
    [class variables:]
cg@2015
    63
cg@2015
    64
    [see also:]
cg@2015
    65
cg@2015
    66
"
cg@2015
    67
!
cg@2015
    68
cg@2015
    69
examples
cg@2015
    70
"
cg@2015
    71
  Starting the application:
cg@2015
    72
                                                                [exBegin]
cg@2015
    73
    InternationalLanguageTranslationEditor open
cg@2015
    74
cg@2015
    75
                                                                [exEnd]
cg@2015
    76
cg@2015
    77
  more examples to be added:
cg@2015
    78
                                                                [exBegin]
cg@2015
    79
    ... add code fragment for 
cg@2015
    80
    ... executable example here ...
cg@2015
    81
                                                                [exEnd]
cg@2015
    82
"
cg@2015
    83
!
cg@2015
    84
cg@2015
    85
history
cg@2015
    86
    "Created: / 04-03-2006 / 09:07:19 / cg"
cg@2015
    87
! !
cg@2015
    88
cg@2015
    89
!InternationalLanguageTranslationEditor class methodsFor:'interface specs'!
cg@2015
    90
cg@2015
    91
windowSpec
cg@2015
    92
    "This resource specification was automatically generated
cg@2015
    93
     by the UIPainter of ST/X."
cg@2015
    94
cg@2015
    95
    "Do not manually edit this!! If it is corrupted,
cg@2015
    96
     the UIPainter may not be able to read the specification."
cg@2015
    97
cg@2015
    98
    "
cg@2048
    99
     UIPainter new openOnClass:Tools::InternationalLanguageTranslationEditor andSelector:#windowSpec
cg@2048
   100
     Tools::InternationalLanguageTranslationEditor new openInterface:#windowSpec
cg@2048
   101
     Tools::InternationalLanguageTranslationEditor open
cg@2015
   102
    "
cg@2015
   103
cg@2015
   104
    <resource: #canvas>
cg@2015
   105
cg@2015
   106
    ^ 
cg@2015
   107
     #(FullSpec
cg@2015
   108
        name: windowSpec
cg@2015
   109
        window: 
cg@2015
   110
       (WindowSpec
cg@2015
   111
          label: 'InternationalLanguageTranslationEditor'
cg@2015
   112
          name: 'InternationalLanguageTranslationEditor'
cg@2015
   113
          min: (Point 10 10)
cg@2015
   114
          max: (Point 1024 768)
cg@2015
   115
          bounds: (Rectangle 0 0 640 400)
cg@2015
   116
          menu: mainMenu
cg@2015
   117
        )
cg@2015
   118
        component: 
cg@2015
   119
       (SpecCollection
cg@2015
   120
          collection: (
cg@2015
   121
           (MenuPanelSpec
cg@2015
   122
              name: 'ToolBar'
cg@2015
   123
              layout: (LayoutFrame 0 0 0 0 0 1 30 0)
cg@2015
   124
              menu: menuToolBar
cg@2015
   125
              textDefault: true
cg@2015
   126
            )
cg@2015
   127
           (VariableVerticalPanelSpec
cg@2015
   128
              name: 'VariableVerticalPanel1'
cg@2015
   129
              layout: (LayoutFrame 0 0 30 0 0 1 0 1)
cg@2015
   130
              component: 
cg@2015
   131
             (SpecCollection
cg@2015
   132
                collection: (
cg@2015
   133
                 (DataSetSpec
cg@2015
   134
                    name: 'KeyStringAndLanguageSelectionTable'
cg@2015
   135
                    model: selectedKeyRow
cg@2015
   136
                    hasHorizontalScrollBar: true
cg@2015
   137
                    hasVerticalScrollBar: true
cg@2015
   138
                    dataList: keyStringAndLanguageSelectionTable
cg@2015
   139
                    columnHolder: keyStringAndLanguageSelectionTableColumnDescriptionHolder
cg@2015
   140
                    columnAdaptor: yourself
cg@2015
   141
                    postBuildCallback: postBuildDataSet:
cg@2015
   142
                  )
cg@2015
   143
                 (ViewSpec
cg@2015
   144
                    name: 'Box1'
cg@2015
   145
                    component: 
cg@2015
   146
                   (SpecCollection
cg@2015
   147
                      collection: (
cg@2015
   148
                       (LabelSpec
cg@2015
   149
                          label: 'Original String (Key):'
cg@2015
   150
                          name: 'Label2'
cg@2015
   151
                          layout: (LayoutFrame 0 0 0 0 0 1 30 0)
cg@2015
   152
                          translateLabel: true
cg@2015
   153
                          adjust: left
cg@2015
   154
                        )
cg@2015
   155
                       (TextEditorSpec
cg@2015
   156
                          name: 'OriginalText'
cg@2015
   157
                          layout: (LayoutFrame 0 0 30 0 0 1 0 1)
cg@2015
   158
                          model: originalTextHolder
cg@2015
   159
                          hasHorizontalScrollBar: true
cg@2015
   160
                          hasVerticalScrollBar: true
cg@2015
   161
                          modifiedChannel: originalTextModifiedHolder
cg@2015
   162
                        )
cg@2015
   163
                       )
cg@2015
   164
                     
cg@2015
   165
                    )
cg@2015
   166
                  )
cg@2015
   167
                 (ViewSpec
cg@2015
   168
                    name: 'Box2'
cg@2015
   169
                    component: 
cg@2015
   170
                   (SpecCollection
cg@2015
   171
                      collection: (
cg@2015
   172
                       (LabelSpec
cg@2015
   173
                          label: 'Translated String:'
cg@2015
   174
                          name: 'Label1'
cg@2015
   175
                          layout: (LayoutFrame 0 0 0 0 0 1 30 0)
cg@2015
   176
                          translateLabel: true
cg@2015
   177
                          adjust: left
cg@2015
   178
                        )
cg@2015
   179
                       (TextEditorSpec
cg@2015
   180
                          name: 'LanguageText'
cg@2015
   181
                          layout: (LayoutFrame 0 0 30 0 0 1 0 1)
cg@2015
   182
                          model: languageTextHolder
cg@2015
   183
                          hasHorizontalScrollBar: true
cg@2015
   184
                          hasVerticalScrollBar: true
cg@2048
   185
                          acceptChannel: languageTextAcceptHolder
cg@2015
   186
                          modifiedChannel: languageTextModifiedHolder
cg@2015
   187
                        )
cg@2015
   188
                       )
cg@2015
   189
                     
cg@2015
   190
                    )
cg@2015
   191
                  )
cg@2015
   192
                 )
cg@2015
   193
               
cg@2015
   194
              )
cg@2015
   195
              handles: (Any 0.33333333333333 0.66666666666667 1.0)
cg@2015
   196
            )
cg@2015
   197
           )
cg@2015
   198
         
cg@2015
   199
        )
cg@2015
   200
      )
cg@2015
   201
! !
cg@2015
   202
cg@2015
   203
!InternationalLanguageTranslationEditor class methodsFor:'menu specs'!
cg@2015
   204
cg@2015
   205
mainMenu
cg@2015
   206
    "This resource specification was automatically generated
cg@2015
   207
     by the MenuEditor of ST/X."
cg@2015
   208
cg@2015
   209
    "Do not manually edit this!! If it is corrupted,
cg@2015
   210
     the MenuEditor may not be able to read the specification."
cg@2015
   211
cg@2015
   212
    "
cg@2015
   213
     MenuEditor new openOnClass:InternationalLanguageTranslationEditor andSelector:#mainMenu
cg@2015
   214
     (Menu new fromLiteralArrayEncoding:(InternationalLanguageTranslationEditor mainMenu)) startUp
cg@2015
   215
    "
cg@2015
   216
cg@2015
   217
    <resource: #menu>
cg@2015
   218
cg@2015
   219
    ^ 
cg@2015
   220
     #(Menu
cg@2015
   221
        (
cg@2015
   222
         (MenuItem
cg@2015
   223
            label: 'File'
cg@2015
   224
            translateLabel: true
cg@2015
   225
            submenu: 
cg@2015
   226
           (Menu
cg@2015
   227
              (
cg@2015
   228
               (MenuItem
cg@2015
   229
                  label: 'New'
cg@2015
   230
                  itemValue: menuNew
cg@2015
   231
                  translateLabel: true
cg@2015
   232
                )
cg@2015
   233
               (MenuItem
cg@2015
   234
                  label: '-'
cg@2015
   235
                )
cg@2015
   236
               (MenuItem
cg@2015
   237
                  label: 'Open Resource File...'
cg@2015
   238
                  itemValue: menuOpen
cg@2015
   239
                  translateLabel: true
cg@2015
   240
                )
cg@2015
   241
               (MenuItem
cg@2015
   242
                  label: '-'
cg@2015
   243
                )
cg@2015
   244
               (MenuItem
cg@2015
   245
                  label: 'Save Resource File'
cg@2015
   246
                  itemValue: menuSave
cg@2015
   247
                  translateLabel: true
cg@2015
   248
                )
cg@2015
   249
               (MenuItem
cg@2015
   250
                  label: 'Save Resource File As...'
cg@2015
   251
                  itemValue: menuSaveAs
cg@2015
   252
                  translateLabel: true
cg@2015
   253
                )
cg@2015
   254
               (MenuItem
cg@2015
   255
                  label: '-'
cg@2015
   256
                )
cg@2015
   257
               (MenuItem
cg@2015
   258
                  label: 'Exit'
cg@2015
   259
                  itemValue: closeRequest
cg@2015
   260
                  translateLabel: true
cg@2015
   261
                )
cg@2015
   262
               )
cg@2015
   263
              nil
cg@2015
   264
              nil
cg@2015
   265
            )
cg@2015
   266
          )
cg@2015
   267
         (MenuItem
cg@2015
   268
            label: 'View'
cg@2015
   269
            translateLabel: true
cg@2015
   270
            submenu: 
cg@2015
   271
           (Menu
cg@2015
   272
              (
cg@2015
   273
               (MenuItem
cg@2015
   274
                  label: 'Show Missing Translations Only'
cg@2015
   275
                  translateLabel: true
cg@2015
   276
                  indication: showMissingTranslationsOnly
cg@2015
   277
                )
cg@2015
   278
               (MenuItem
cg@2015
   279
                  label: '-'
cg@2015
   280
                )
cg@2015
   281
               (MenuItem
cg@2015
   282
                  label: 'Shown Languages'
cg@2015
   283
                  translateLabel: true
cg@2015
   284
                  submenuChannel: shownLanguagesMenu
cg@2015
   285
                )
cg@2015
   286
               )
cg@2015
   287
              nil
cg@2015
   288
              nil
cg@2015
   289
            )
cg@2015
   290
          )
cg@2015
   291
         (MenuItem
cg@2015
   292
            label: 'Languages'
cg@2015
   293
            translateLabel: true
cg@2015
   294
            submenu: 
cg@2015
   295
           (Menu
cg@2015
   296
              (
cg@2015
   297
               (MenuItem
cg@2015
   298
                  label: 'Add Language...'
cg@2015
   299
                  itemValue: addLanguage
cg@2015
   300
                  translateLabel: true
cg@2015
   301
                )
cg@2015
   302
               (MenuItem
cg@2015
   303
                  label: 'Remove Language...'
cg@2015
   304
                  itemValue: removeLanguage
cg@2015
   305
                  translateLabel: true
cg@2015
   306
                )
cg@2015
   307
               )
cg@2015
   308
              nil
cg@2015
   309
              nil
cg@2015
   310
            )
cg@2015
   311
          )
cg@2015
   312
         (MenuItem
cg@2015
   313
            label: 'Translations'
cg@2015
   314
            translateLabel: true
cg@2015
   315
            submenu: 
cg@2015
   316
           (Menu
cg@2015
   317
              (
cg@2015
   318
               (MenuItem
cg@2015
   319
                  label: 'Add Translation...'
cg@2015
   320
                  itemValue: addTranslation
cg@2015
   321
                  translateLabel: true
cg@2015
   322
                )
cg@2015
   323
               (MenuItem
cg@2015
   324
                  label: 'Remove Translation...'
cg@2015
   325
                  itemValue: removeTranslation
cg@2015
   326
                  translateLabel: true
cg@2015
   327
                )
cg@2015
   328
               (MenuItem
cg@2015
   329
                  label: '-'
cg@2015
   330
                )
cg@2015
   331
               (MenuItem
cg@2015
   332
                  label: 'Extract from Class...'
cg@2015
   333
                  itemValue: extractTranslationsFromClass
cg@2015
   334
                  translateLabel: true
cg@2015
   335
                )
cg@2015
   336
               (MenuItem
cg@2032
   337
                  label: 'Extract from Project...'
cg@2032
   338
                  itemValue: extractTranslationsFromProject
cg@2032
   339
                  translateLabel: true
cg@2032
   340
                )
cg@2032
   341
               (MenuItem
cg@2032
   342
                  label: '-'
cg@2032
   343
                )
cg@2032
   344
               (MenuItem
cg@2015
   345
                  label: 'Run Application and Collect Translations...'
cg@2015
   346
                  itemValue: runApplicationAndCollectTranslations
cg@2015
   347
                  translateLabel: true
cg@2015
   348
                )
cg@2015
   349
               )
cg@2015
   350
              nil
cg@2015
   351
              nil
cg@2015
   352
            )
cg@2015
   353
          )
cg@2015
   354
         (MenuItem
cg@2015
   355
            label: 'Help'
cg@2015
   356
            translateLabel: true
cg@2015
   357
            startGroup: right
cg@2015
   358
            submenu: 
cg@2015
   359
           (Menu
cg@2015
   360
              (
cg@2015
   361
               (MenuItem
cg@2015
   362
                  label: 'Documentation'
cg@2015
   363
                  itemValue: openDocumentation
cg@2015
   364
                  translateLabel: true
cg@2015
   365
                )
cg@2015
   366
               (MenuItem
cg@2015
   367
                  label: '-'
cg@2015
   368
                )
cg@2015
   369
               (MenuItem
cg@2015
   370
                  label: 'About this Application...'
cg@2015
   371
                  itemValue: openAboutThisApplication
cg@2015
   372
                  translateLabel: true
cg@2015
   373
                )
cg@2015
   374
               )
cg@2015
   375
              nil
cg@2015
   376
              nil
cg@2015
   377
            )
cg@2015
   378
          )
cg@2015
   379
         )
cg@2015
   380
        nil
cg@2015
   381
        nil
cg@2015
   382
      )
cg@2015
   383
!
cg@2015
   384
cg@2015
   385
menuToolBar
cg@2015
   386
    "This resource specification was automatically generated
cg@2015
   387
     by the MenuEditor of ST/X."
cg@2015
   388
cg@2015
   389
    "Do not manually edit this!! If it is corrupted,
cg@2015
   390
     the MenuEditor may not be able to read the specification."
cg@2015
   391
cg@2015
   392
    "
cg@2015
   393
     MenuEditor new openOnClass:InternationalLanguageTranslationEditor andSelector:#menuToolBar
cg@2015
   394
     (Menu new fromLiteralArrayEncoding:(InternationalLanguageTranslationEditor menuToolBar)) startUp
cg@2015
   395
    "
cg@2015
   396
cg@2015
   397
    <resource: #menu>
cg@2015
   398
cg@2015
   399
    ^ 
cg@2015
   400
     #(Menu
cg@2015
   401
        (
cg@2015
   402
         (MenuItem
cg@2015
   403
            label: 'Save'
cg@2015
   404
            translateLabel: true
cg@2015
   405
            labelImage: (ResourceRetriever XPToolbarIconLibrary saveImageIcon)
cg@2015
   406
          )
cg@2015
   407
         (MenuItem
cg@2015
   408
            label: '-'
cg@2015
   409
          )
cg@2015
   410
         (MenuItem
cg@2015
   411
            label: 'Add Translation'
cg@2015
   412
            itemValue: addTranslation
cg@2015
   413
            translateLabel: true
cg@2015
   414
            labelImage: (ResourceRetriever XPToolbarIconLibrary newRowIcon)
cg@2015
   415
          )
cg@2015
   416
         (MenuItem
cg@2015
   417
            label: 'Remove Translation'
cg@2015
   418
            itemValue: removeTranslation
cg@2015
   419
            translateLabel: true
cg@2015
   420
            labelImage: (ResourceRetriever XPToolbarIconLibrary removeRowIcon)
cg@2015
   421
          )
cg@2015
   422
         (MenuItem
cg@2015
   423
            label: ''
cg@2015
   424
          )
cg@2015
   425
         (MenuItem
cg@2015
   426
            label: 'Stop Application'
cg@2015
   427
            itemValue: stopApplication
cg@2015
   428
            translateLabel: true
cg@2015
   429
            isVisible: stopApplicationIconVisibleHolder
cg@2015
   430
            labelImage: (ResourceRetriever XPToolbarIconLibrary stop16x16Icon)
cg@2015
   431
          )
cg@2015
   432
         )
cg@2015
   433
        nil
cg@2015
   434
        nil
cg@2015
   435
      )
cg@2015
   436
! !
cg@2015
   437
cg@2047
   438
!InternationalLanguageTranslationEditor class methodsFor:'tableColumns specs'!
cg@2047
   439
cg@2047
   440
keyTableColumn
cg@2047
   441
    "This resource specification was automatically generated
cg@2047
   442
     by the DataSetBuilder of ST/X."
cg@2047
   443
cg@2047
   444
    "Do not manually edit this!! If it is corrupted,
cg@2047
   445
     the DataSetBuilder may not be able to read the specification."
cg@2047
   446
cg@2047
   447
    "
cg@2047
   448
     DataSetBuilder new openOnClass:Tools::InternationalLanguageTranslationEditor andSelector:#keyTableColumn
cg@2047
   449
    "
cg@2047
   450
cg@2047
   451
    <resource: #tableColumns>
cg@2047
   452
cg@2047
   453
    ^#(
cg@2047
   454
      (DataSetColumnSpec
cg@2047
   455
         label: 'Key'
cg@2047
   456
         labelButtonType: Button
cg@2047
   457
         minWidth: 50
cg@2047
   458
         model: keyStringInRow:
cg@2047
   459
       )
cg@2047
   460
      )
cg@2047
   461
!
cg@2047
   462
cg@2047
   463
languageTableColumn
cg@2047
   464
    "This resource specification was automatically generated
cg@2047
   465
     by the DataSetBuilder of ST/X."
cg@2047
   466
cg@2047
   467
    "Do not manually edit this!! If it is corrupted,
cg@2047
   468
     the DataSetBuilder may not be able to read the specification."
cg@2047
   469
cg@2047
   470
    "
cg@2047
   471
     DataSetBuilder new openOnClass:Tools::InternationalLanguageTranslationEditor andSelector:#keyTableColumn
cg@2047
   472
    "
cg@2047
   473
cg@2047
   474
    <resource: #tableColumns>
cg@2047
   475
cg@2047
   476
    ^#(
cg@2047
   477
              #(DataSetColumnSpec
cg@2047
   478
                 label: #lang
cg@2047
   479
                 labelAlignment: center
cg@2047
   480
                 labelButtonType: Button
cg@2047
   481
                 minWidth: 50
cg@2047
   482
                 model: #columnInRow:at:
cg@2047
   483
                 canSelect: true
cg@2047
   484
                 isResizeable: true
cg@2047
   485
                 showRowSeparator: true
cg@2047
   486
                 showColSeparator: true
cg@2047
   487
                 backgroundSelector: #getBackgroundForRow:rowNr:col:
cg@2047
   488
               )
cg@2047
   489
cg@2047
   490
      )
cg@2047
   491
! !
cg@2047
   492
cg@2015
   493
!InternationalLanguageTranslationEditor methodsFor:'aspects'!
cg@2015
   494
cg@2015
   495
keyStringAndLanguageSelectionTable
cg@2015
   496
    keyStringsToLanguageMappings isNil ifTrue:[
cg@2015
   497
        keyStringsToLanguageMappings := KeyStringsToLanguageMappings new.
cg@2015
   498
    ].
cg@2015
   499
    ^ keyStringsToLanguageMappings.
cg@2015
   500
!
cg@2015
   501
cg@2015
   502
keyStringAndLanguageSelectionTableColumnDescriptionHolder
cg@2015
   503
    keyStringAndLanguageSelectionTableColumnDescriptionHolder isNil ifTrue:[
cg@2015
   504
        keyStringAndLanguageSelectionTableColumnDescriptionHolder := ValueHolder new.
cg@2015
   505
        keyStringAndLanguageSelectionTableColumnDescriptionHolder value:(self keyStringAndLanguageSelectionTableColumnDescription).
cg@2015
   506
    ].
cg@2015
   507
    ^ keyStringAndLanguageSelectionTableColumnDescriptionHolder.
cg@2015
   508
!
cg@2015
   509
cg@2015
   510
languageAtCol:colNr
cg@2015
   511
    ^ shownLanguages at:colNr-1.
cg@2015
   512
!
cg@2015
   513
cg@2015
   514
languageShownHolderFor:lang
cg@2015
   515
    |holder|
cg@2015
   516
cg@2015
   517
    languageShownHolders isNil ifTrue:[
cg@2015
   518
        languageShownHolders := Dictionary new
cg@2015
   519
    ].
cg@2015
   520
    holder := languageShownHolders 
cg@2015
   521
                at:lang 
cg@2015
   522
                ifAbsentPut:[ 
cg@2015
   523
                    |h|
cg@2015
   524
cg@2015
   525
                    h := true asValue.
cg@2015
   526
                    h onChangeEvaluate:[ 
cg@2015
   527
                        h value ifTrue:[
cg@2015
   528
                           self enableLanguageDisplayFor:lang     
cg@2015
   529
                        ] ifFalse:[
cg@2015
   530
                           self disableLanguageDisplayFor:lang     
cg@2015
   531
                        ].
cg@2015
   532
                    ].
cg@2015
   533
                    h
cg@2015
   534
                ].
cg@2015
   535
    ^ holder.
cg@2015
   536
!
cg@2015
   537
cg@2048
   538
languageTextAcceptHolder
cg@2048
   539
    languageTextAcceptHolder isNil ifTrue:[
cg@2048
   540
        languageTextAcceptHolder := false asValue.
cg@2048
   541
    ].
cg@2048
   542
    ^ languageTextAcceptHolder.
cg@2048
   543
!
cg@2048
   544
cg@2015
   545
languageTextHolder
cg@2015
   546
    languageTextHolder isNil ifTrue:[
cg@2015
   547
        languageTextHolder := '' asValue.
cg@2015
   548
    ].
cg@2015
   549
    ^ languageTextHolder.
cg@2015
   550
!
cg@2015
   551
cg@2015
   552
languageTextModifiedHolder
cg@2015
   553
    languageTextModifiedHolder isNil ifTrue:[
cg@2015
   554
        languageTextModifiedHolder := false asValue.
cg@2015
   555
    ].
cg@2015
   556
    ^ languageTextModifiedHolder.
cg@2015
   557
!
cg@2015
   558
cg@2015
   559
languagesList
cg@2015
   560
    languagesList isNil ifTrue:[
cg@2015
   561
        languagesList := List withAll:(self keyStringAndLanguageSelectionTable languages).
cg@2015
   562
    ].
cg@2015
   563
    ^ languagesList.
cg@2015
   564
!
cg@2015
   565
cg@2015
   566
originalTextHolder
cg@2015
   567
    originalTextHolder isNil ifTrue:[
cg@2015
   568
        originalTextHolder := '' asValue.
cg@2015
   569
    ].
cg@2015
   570
    ^ originalTextHolder.
cg@2015
   571
!
cg@2015
   572
cg@2015
   573
originalTextModifiedHolder
cg@2015
   574
    originalTextModifiedHolder isNil ifTrue:[
cg@2015
   575
        originalTextModifiedHolder := false asValue.
cg@2015
   576
    ].
cg@2015
   577
    ^ originalTextModifiedHolder.
cg@2015
   578
!
cg@2015
   579
cg@2015
   580
selectedKeyRow
cg@2015
   581
    selectedKeyRow isNil ifTrue:[
cg@2015
   582
        selectedKeyRow := ValueHolder new.
cg@2015
   583
        selectedKeyRow onChangeSend:#selectionChanged to:self.
cg@2015
   584
    ].
cg@2015
   585
    ^ selectedKeyRow.
cg@2015
   586
!
cg@2015
   587
cg@2015
   588
showMissingTranslationsOnly
cg@2015
   589
    showMissingTranslationsOnly isNil ifTrue:[
cg@2015
   590
        showMissingTranslationsOnly := false asValue.
cg@2015
   591
    ].
cg@2015
   592
    ^ showMissingTranslationsOnly.
cg@2015
   593
!
cg@2015
   594
cg@2015
   595
shownLanguages
cg@2015
   596
    shownLanguages isNil ifTrue:[
cg@2015
   597
        shownLanguages := List new.
cg@2015
   598
        shownLanguages addAll:(self languagesList).
cg@2048
   599
        "/ shownLanguages addDependent:self. 
cg@2015
   600
        shownLanguages onChangeSend:#shownLanguagesChanged to:self.
cg@2015
   601
    ].
cg@2015
   602
    ^ shownLanguages.
cg@2015
   603
!
cg@2015
   604
cg@2015
   605
stopApplicationIconVisibleHolder
cg@2015
   606
    stopApplicationIconVisibleHolder isNil ifTrue:[
cg@2015
   607
        stopApplicationIconVisibleHolder := false asValue.
cg@2015
   608
    ].
cg@2015
   609
    ^ stopApplicationIconVisibleHolder.
cg@2015
   610
! !
cg@2015
   611
cg@2048
   612
!InternationalLanguageTranslationEditor methodsFor:'change & update'!
cg@2048
   613
cg@2048
   614
update:something with:aParameter from:changedObject
cg@2048
   615
    changedObject == shownLanguages ifTrue:[
cg@2048
   616
         self shownLanguagesChanged.
cg@2048
   617
         ^ self.
cg@2048
   618
    ].
cg@2048
   619
! !
cg@2048
   620
cg@2015
   621
!InternationalLanguageTranslationEditor methodsFor:'initialization & release'!
cg@2015
   622
cg@2015
   623
closeRequest
cg@2015
   624
    "asks for permission before closing"
cg@2015
   625
cg@2015
   626
    self hasUnsavedChanges ifTrue:[
cg@2015
   627
        (Dialog 
cg@2015
   628
            confirm:(resources string:'Close without saving ?')
cg@2015
   629
            default:false) ifFalse:[
cg@2015
   630
            ^ self
cg@2015
   631
        ]
cg@2015
   632
    ].
cg@2015
   633
cg@2015
   634
    super closeRequest
cg@2015
   635
!
cg@2015
   636
cg@2015
   637
initialize
cg@2015
   638
    modified := false.
cg@2031
   639
    inSingleFileMode := false.
cg@2015
   640
    super initialize
cg@2015
   641
!
cg@2015
   642
cg@2015
   643
postBuildDataSet:aView
cg@2015
   644
    dataSetView := aView
cg@2015
   645
! !
cg@2015
   646
cg@2015
   647
!InternationalLanguageTranslationEditor methodsFor:'menu actions'!
cg@2015
   648
cg@2015
   649
addLanguage
cg@2015
   650
    |lang|
cg@2015
   651
cg@2015
   652
    lang := Dialog request:'New language (ISO symbol):'.
cg@2015
   653
    lang isEmptyOrNil ifTrue:[^ self].
cg@2015
   654
cg@2015
   655
    (keyStringsToLanguageMappings includesLanguage:lang) ifTrue:[^ self ].
cg@2015
   656
cg@2015
   657
    keyStringsToLanguageMappings addLanguage:lang.
cg@2015
   658
    self languagesList add:lang.
cg@2015
   659
    self shownLanguages add:lang.
cg@2015
   660
    modified := true.
cg@2015
   661
!
cg@2015
   662
cg@2015
   663
addTranslation
cg@2015
   664
    |key index|
cg@2015
   665
cg@2015
   666
    key := Dialog request:'New Key:'.
cg@2015
   667
    (keyStringsToLanguageMappings includesKey:key) ifFalse:[
cg@2015
   668
        keyStringsToLanguageMappings addKey:key.
cg@2015
   669
        modified := true.
cg@2015
   670
    ].
cg@2015
   671
    index := keyStringsToLanguageMappings indexOfKey:key.
cg@2015
   672
cg@2015
   673
    self selectedKeyRow value:index
cg@2015
   674
!
cg@2015
   675
cg@2015
   676
extractTranslationsFromClass
cg@2015
   677
    |aClass newTranslations|
cg@2015
   678
cg@2015
   679
    aClass := Dialog 
cg@2015
   680
                requestClass:'Class to extract translations from:'
cg@2015
   681
                okLabel:'OK' 
cg@2015
   682
                initialAnswer:(lastExtractedClass ? LastExtractedClass).
cg@2015
   683
    aClass isNil ifTrue:[^ self ].
cg@2015
   684
cg@2015
   685
    lastExtractedClass := LastExtractedClass := aClass.
cg@2015
   686
cg@2032
   687
    newTranslations := self extractTranslationsFromClass:aClass.
cg@2032
   688
    self addAllTranslations:newTranslations.
cg@2032
   689
!
cg@2032
   690
cg@2032
   691
extractTranslationsFromProject
cg@2032
   692
    |box projectID newTranslations|
cg@2032
   693
cg@2032
   694
    box := ListSelectionBox new.
cg@2032
   695
"/    box useComboBoxWithList:(Smalltalk allProjectIDs).
cg@2032
   696
    box title:(resources string:'Project to extract translations from:').
cg@2032
   697
    box list:Smalltalk allProjectIDs.
cg@2032
   698
    box okAction:[:sel | projectID := sel].
cg@2032
   699
    box initialText:(lastExtractedProject ? LastExtractedProject).
cg@2032
   700
    box label:'Find Translations in Project'.
cg@2032
   701
cg@2032
   702
    box showAtPointer.
cg@2032
   703
cg@2032
   704
    projectID notNil ifTrue:[
cg@2032
   705
        projectID := projectID withoutSeparators asSymbol.
cg@2032
   706
    ].
cg@2032
   707
    projectID isEmptyOrNil ifTrue:[^ self ].
cg@2032
   708
cg@2032
   709
    lastExtractedProject := LastExtractedProject := projectID.
cg@2032
   710
cg@2015
   711
    newTranslations := Set new.
cg@2015
   712
cg@2032
   713
    Smalltalk allClassesDo:[:eachClass |
cg@2032
   714
        eachClass theNonMetaclass package == projectID ifTrue:[
cg@2032
   715
"/ eachClass isLoaded ifTrue:[ self halt. ].
cg@2032
   716
            newTranslations addAll:( self extractTranslationsFromClass:eachClass theNonMetaclass).
cg@2032
   717
        ]
cg@2015
   718
    ].
cg@2015
   719
cg@2032
   720
    self addAllTranslations:newTranslations.
cg@2015
   721
!
cg@2015
   722
cg@2015
   723
menuNew
cg@2015
   724
    modified ifTrue:[
cg@2015
   725
        (Dialog 
cg@2015
   726
            confirm:(resources stringWithCRs:'Modified translations have not been changed.\\Create new translations set anyway ?')
cg@2015
   727
            default:false) ifFalse:[^ self].
cg@2015
   728
    ].
cg@2015
   729
cg@2015
   730
    keyStringsToLanguageMappings initialize.
cg@2015
   731
    keyStringsToLanguageMappings changed.
cg@2015
   732
cg@2015
   733
    self languagesList contents:self keyStringAndLanguageSelectionTable languages.
cg@2015
   734
    self shownLanguages contents:self keyStringAndLanguageSelectionTable languages.
cg@2015
   735
    modified := false.
cg@2015
   736
!
cg@2015
   737
cg@2015
   738
menuOpen
cg@2015
   739
    |fn|
cg@2015
   740
cg@2015
   741
    fn := Dialog 
cg@2015
   742
        requestFileName:'Name of resource file:'
cg@2015
   743
        default:nil 
cg@2015
   744
        pattern:'*.rs'.
cg@2015
   745
cg@2015
   746
    fn isEmptyOrNil ifTrue:[^ self ].
cg@2015
   747
    fn := fn asFilename.
cg@2015
   748
    fn exists ifFalse:[^ self ].
cg@2015
   749
cg@2015
   750
    self readResourceFile:fn
cg@2015
   751
!
cg@2015
   752
cg@2015
   753
menuSave
cg@2015
   754
    "This method was generated by the Browser.
cg@2015
   755
     It will be invoked when the menu-item 'save' is selected."
cg@2015
   756
cg@2015
   757
    "/ change below and add any actions as required here ...
cg@2015
   758
    self warn:'no action for ''save'' available.'.
cg@2015
   759
!
cg@2015
   760
cg@2015
   761
menuSaveAs
cg@2015
   762
    "This method was generated by the Browser.
cg@2015
   763
     It will be invoked when the menu-item 'saveAs' is selected."
cg@2015
   764
cg@2015
   765
    "/ change below and add any actions as required here ...
cg@2015
   766
    self warn:'no action for ''saveAs'' available.'.
cg@2015
   767
!
cg@2015
   768
cg@2015
   769
openAboutThisApplication
cg@2015
   770
    "This method was generated by the Browser.
cg@2015
   771
     It will be invoked when the menu-item 'help-about' is selected."
cg@2015
   772
cg@2015
   773
    "/ could open a customized aboutBox here ...
cg@2015
   774
    super openAboutThisApplication
cg@2015
   775
!
cg@2015
   776
cg@2015
   777
openDocumentation
cg@2015
   778
    "This method was generated by the Browser.
cg@2015
   779
     It will be invoked when the menu-item 'help-documentation' is selected."
cg@2015
   780
cg@2015
   781
    "/ change below as required ...
cg@2015
   782
cg@2015
   783
    "/ to open an HTML viewer on some document (under 'doc/online/<language>/' ):
cg@2015
   784
    HTMLDocumentView openFullOnDocumentationFile:'TOP.html'.
cg@2015
   785
cg@2015
   786
    "/ add application-specific help files under the 'doc/online/<language>/help/appName'
cg@2015
   787
    "/ directory, and open a viewer with:
cg@2015
   788
    "/ HTMLDocumentView openFullOnDocumentationFile:'help/<MyApplication>/TOP.html'.
cg@2015
   789
!
cg@2015
   790
cg@2015
   791
readResourceFile:aFilename
cg@2031
   792
    |lang|
cg@2031
   793
cg@2031
   794
    lang := Dialog choose:'For which language ?' fromList:languagesList lines:10.
cg@2031
   795
    lang isNil ifTrue:[^ self ].
cg@2031
   796
cg@2031
   797
    self readResourceFile:aFilename asLanguage:lang asSymbol
cg@2031
   798
!
cg@2031
   799
cg@2031
   800
readResourceFile:aFilename asLanguage:lang
cg@2031
   801
    |resourcePack inStream lineString encoding decoder sortedKeys remainingKeys|
cg@2015
   802
cg@2015
   803
    aFilename exists ifFalse:[^ self ].
cg@2015
   804
cg@2031
   805
    resourcePack := ResourcePack new.
cg@2031
   806
cg@2015
   807
    inStream := aFilename readStream.
cg@2015
   808
    [inStream atEnd] whileFalse:[
cg@2015
   809
        lineString := inStream nextLine.
cg@2015
   810
        (lineString notEmpty 
cg@2015
   811
        and:[ (lineString startsWith:';') not ]) ifTrue:[
cg@2031
   812
            ((lineString startsWith:'#') and:[(lineString startsWith:'#(') not]) ifTrue:[
cg@2031
   813
                lineString := (lineString copyFrom:2) withoutSeparators.
cg@2031
   814
                (lineString startsWith:'encoding ') ifTrue:[
cg@2031
   815
                    encoding := ResourcePack extractEncodingFromLine:lineString.
cg@2031
   816
                    decoder := CharacterEncoder encoderFor:encoding ifAbsent:nil.
cg@2031
   817
                ].
cg@2015
   818
            ] ifFalse:[
cg@2031
   819
                ResourcePack
cg@2031
   820
                    processResourceLine:lineString 
cg@2031
   821
                    encoding:decoder 
cg@2031
   822
                    file:aFilename pathName 
cg@2031
   823
                    printErrorWith:[:msg | Transcript showCR:msg ] 
cg@2031
   824
                    for:resourcePack
cg@2031
   825
                    keepUselessTranslations:true.
cg@2015
   826
            ].
cg@2015
   827
        ].
cg@2015
   828
    ].
cg@2015
   829
    inStream close.
cg@2031
   830
cg@2031
   831
    sortedKeys := (resourcePack keys select:[:k | k isString]) asSortedCollection.
cg@2031
   832
    remainingKeys := resourcePack keys select:[:k | k isString not].
cg@2031
   833
cg@2031
   834
    sortedKeys do:[:k |
cg@2031
   835
        keyStringsToLanguageMappings at:k language:lang put:(resourcePack at:k)
cg@2031
   836
    ].
cg@2031
   837
    remainingKeys do:[:k |
cg@2031
   838
        keyStringsToLanguageMappings at:k language:lang put:(resourcePack at:k)
cg@2031
   839
    ].
cg@2015
   840
!
cg@2015
   841
cg@2015
   842
removeLanguage
cg@2015
   843
    "automatically generated by UIEditor ..."
cg@2015
   844
cg@2015
   845
    "*** the code below performs no action"
cg@2015
   846
    "*** (except for some feedback on the Transcript)"
cg@2015
   847
    "*** Please change as required and accept in the browser."
cg@2015
   848
    "*** (and replace this comment by something more useful ;-)"
cg@2015
   849
cg@2015
   850
    "action to be added ..."
cg@2015
   851
cg@2015
   852
    Transcript showCR:self class name, ': action for #removeLanguage ...'.
cg@2015
   853
!
cg@2015
   854
cg@2015
   855
removeTranslation
cg@2015
   856
    |rowSelectionIndex selectedKey|
cg@2015
   857
cg@2015
   858
    rowSelectionIndex := self selectedKeyRow value.
cg@2015
   859
    rowSelectionIndex ~~ 0 ifTrue:[
cg@2015
   860
        selectedKey := keyStringsToLanguageMappings keyAt:rowSelectionIndex ifAbsent:nil.
cg@2015
   861
        (Dialog confirm:(resources string:'Really remove key %1' with:selectedKey)) ifTrue:[
cg@2015
   862
            keyStringsToLanguageMappings removeKey:selectedKey.
cg@2015
   863
        ].
cg@2015
   864
    ].
cg@2015
   865
!
cg@2015
   866
cg@2015
   867
runApplicationAndCollectTranslations
cg@2047
   868
    |applicationClass newTranslations pseudoPack app startSelector|
cg@2015
   869
cg@2015
   870
    monitoredApplication notNil ifTrue:[
cg@2015
   871
        monitoredApplication terminate.
cg@2015
   872
        [monitoredApplication notNil] whileTrue:[
cg@2015
   873
            Delay waitForSeconds:0.1
cg@2015
   874
        ].
cg@2015
   875
    ].
cg@2015
   876
cg@2015
   877
    applicationClass := Dialog 
cg@2015
   878
                requestClass:'Application class to start and collect translations from:'
cg@2015
   879
                okLabel:'OK' 
cg@2015
   880
                initialAnswer:(lastExtractedApplicationClass ? LastExtractedApplicationClass ).
cg@2015
   881
    applicationClass isNil ifTrue:[^ self ].
cg@2047
   882
    applicationClass isNamespace ifTrue:[
cg@2047
   883
        Dialog warn:'Entered class is a NameSpace'.
cg@2047
   884
        ^ self.
cg@2047
   885
    ].
cg@2047
   886
cg@2047
   887
    applicationClass isVisualStartable ifTrue:[
cg@2047
   888
        startSelector := #open
cg@2047
   889
    ] ifFalse:[
cg@2047
   890
        startSelector := Dialog
cg@2047
   891
                    request:'Entered class seems to be no application class. Ok to start using selector:'
cg@2047
   892
                    initialAnswer:((applicationClass respondsTo:#'start')
cg@2047
   893
                                        ifTrue:#'start'
cg@2047
   894
                                        ifFalse:#'new')
cg@2047
   895
                    okLabel:'START'
cg@2047
   896
                    title:'Start Application'.
cg@2047
   897
        startSelector isNil ifTrue:[
cg@2047
   898
            ^ self
cg@2047
   899
        ].
cg@2047
   900
        startSelector := startSelector asSymbol.
cg@2047
   901
    ].
cg@2015
   902
cg@2015
   903
    lastExtractedApplicationClass := LastExtractedApplicationClass := applicationClass.
cg@2015
   904
cg@2015
   905
    newTranslations := Set new.
cg@2015
   906
cg@2015
   907
    pseudoPack := AccessCollectingPseudoResourcePack new.
cg@2015
   908
    pseudoPack realResourcePack:(applicationClass classResources).
cg@2015
   909
cg@2015
   910
    self stopApplicationIconVisibleHolder value:true.
cg@2015
   911
cg@2015
   912
    monitoredApplication := [
cg@2015
   913
        [
cg@2015
   914
            app := applicationClass new.
cg@2047
   915
            app perform:startSelector.
cg@2015
   916
            app window waitUntilVisible.
cg@2015
   917
            app window waitUntilClosed.
cg@2015
   918
        ] ensure:[
cg@2015
   919
            app closeRequest.
cg@2015
   920
            self stopApplicationIconVisibleHolder value:false.
cg@2015
   921
            monitoredApplication := nil.
cg@2015
   922
        ].
cg@2015
   923
    ] fork.
cg@2015
   924
! !
cg@2015
   925
cg@2015
   926
!InternationalLanguageTranslationEditor methodsFor:'menus dynamic'!
cg@2015
   927
cg@2015
   928
disableLanguageDisplayFor:lang
cg@2015
   929
    self shownLanguages remove:lang ifAbsent:[]
cg@2015
   930
!
cg@2015
   931
cg@2015
   932
enableLanguageDisplayFor:newLang
cg@2015
   933
    |shownLanguagesInOrder|
cg@2015
   934
cg@2015
   935
    (self shownLanguages includes:newLang) ifFalse:[
cg@2048
   936
"/        shownLanguagesInOrder := self languagesList
cg@2048
   937
"/                                    select:[:lang | (self shownLanguages includes:lang)
cg@2048
   938
"/                                                    or:[ lang = newLang ]].
cg@2048
   939
"/        self shownLanguages contents:shownLanguagesInOrder.
cg@2048
   940
        self shownLanguages add:newLang.
cg@2015
   941
    ]
cg@2015
   942
!
cg@2015
   943
cg@2015
   944
isLanguageShown:lang
cg@2015
   945
    ^ self shownLanguages includes:lang
cg@2015
   946
!
cg@2015
   947
cg@2015
   948
shownLanguagesMenu
cg@2015
   949
    <resource: #programMenu >
cg@2015
   950
cg@2015
   951
    ^ [
cg@2015
   952
        |m selected|
cg@2015
   953
cg@2015
   954
        m := Menu new.
cg@2015
   955
cg@2015
   956
        self languagesList do:[:lang |
cg@2015
   957
            |item|
cg@2015
   958
cg@2015
   959
            item := MenuItem label:lang.
cg@2015
   960
            item indication:(self languageShownHolderFor:lang).
cg@2015
   961
            item hideMenuOnActivated:false.    
cg@2015
   962
            m addItem:item.
cg@2015
   963
        ].
cg@2015
   964
        m
cg@2015
   965
    ].
cg@2015
   966
!
cg@2015
   967
cg@2015
   968
toggleLanguageDisplayFor:lang
cg@2015
   969
    (self shownLanguages includes:lang) ifTrue:[
cg@2015
   970
        self disableLanguageDisplayFor:lang
cg@2015
   971
    ] ifFalse:[
cg@2015
   972
        self enableLanguageDisplayFor:lang
cg@2015
   973
    ].
cg@2015
   974
! !
cg@2015
   975
cg@2015
   976
!InternationalLanguageTranslationEditor methodsFor:'private-key extraction'!
cg@2015
   977
cg@2032
   978
addAllTranslations:newTranslations
cg@2034
   979
    |newTranslationKeys stringKeys nonStringKeys|
cg@2032
   980
cg@2034
   981
    newTranslationKeys := newTranslations select:[:k | k notEmpty and:[k isString not or:[k isBlank not]]].
cg@2032
   982
    newTranslationKeys := newTranslationKeys select:[:k | (keyStringsToLanguageMappings includesKey:k) not].
cg@2034
   983
    newTranslationKeys := newTranslationKeys 
cg@2034
   984
                                collect:[:k | 
cg@2034
   985
                                        (k endsWith:'...') ifTrue:[
cg@2034
   986
                                            k copyWithoutLast:3.
cg@2034
   987
                                        ] ifFalse:[
cg@2035
   988
                                            ('.:?' includes:k last) ifTrue:[
cg@2034
   989
                                                k copyWithoutLast:1.
cg@2034
   990
                                            ] ifFalse:[
cg@2034
   991
                                                k
cg@2034
   992
                                        ]]].
cg@2034
   993
    newTranslationKeys := newTranslationKeys asSet.
cg@2034
   994
cg@2032
   995
    newTranslationKeys notEmpty ifTrue:[
cg@2034
   996
        stringKeys := newTranslationKeys select:[:k | k isString].
cg@2034
   997
        nonStringKeys := newTranslationKeys select:[:k | k isString not].
cg@2034
   998
cg@2034
   999
        stringKeys := stringKeys asSortedCollection.
cg@2034
  1000
        keyStringsToLanguageMappings addKeys:stringKeys.
cg@2034
  1001
        keyStringsToLanguageMappings addKeys:nonStringKeys.
cg@2032
  1002
        modified := true.
cg@2032
  1003
    ].
cg@2032
  1004
!
cg@2032
  1005
cg@2032
  1006
extractTranslationsFromClass:aClass
cg@2032
  1007
    |newTranslations|
cg@2032
  1008
cg@2032
  1009
    newTranslations := Set new.
cg@2032
  1010
cg@2032
  1011
    self withWaitCursorDo:[
cg@2032
  1012
        "/ now, the hard part:
cg@2032
  1013
        "/ possible translations are in the specs,
cg@2032
  1014
        "/ and all arguments to (resources string:) messages.
cg@2032
  1015
        aClass instAndClassMethodsDo:[:eachMethod |
cg@2032
  1016
            newTranslations addAll:( self extractTranslationsFromMethod:eachMethod ).
cg@2032
  1017
        ].
cg@2032
  1018
    ].
cg@2032
  1019
    ^ newTranslations
cg@2032
  1020
!
cg@2032
  1021
cg@2015
  1022
extractTranslationsFromHelpSpecMethod:aMethod
cg@2015
  1023
    |codeStrings matcher parseTree resourceKeys|
cg@2015
  1024
cg@2015
  1025
    parseTree := RBParser 
cg@2015
  1026
            parseMethod:aMethod source 
cg@2015
  1027
            onError: [:str :pos | Transcript showCR:str. Transcript showCR:pos.
cg@2015
  1028
                                  nil].
cg@2015
  1029
    parseTree isNil ifTrue:[^ #() ].
cg@2015
  1030
cg@2015
  1031
    codeStrings  := 
cg@2015
  1032
        #(
cg@2015
  1033
                '`@dict addPairsFrom: `#helpKeysAndStrings'
cg@2015
  1034
        ).
cg@2015
  1035
cg@2015
  1036
    resourceKeys := Set new.
cg@2015
  1037
cg@2015
  1038
    matcher := ParseTreeSearcher new.
cg@2015
  1039
    matcher 
cg@2015
  1040
        matchesAnyOf: codeStrings 
cg@2015
  1041
        do: [:aNode :answer |
cg@2015
  1042
                |sel argNode arg|
cg@2015
  1043
cg@2015
  1044
                sel := aNode selector.
cg@2015
  1045
                (sel startsWith:'addPairsFrom:') ifTrue:[
cg@2015
  1046
                    argNode := aNode arguments at:1.
cg@2015
  1047
                    argNode isLiteral ifTrue:[
cg@2015
  1048
                        arg := argNode value.
cg@2015
  1049
                        arg isArray ifTrue:[
cg@2015
  1050
                            arg doWithIndex:[:el :index |
cg@2015
  1051
                                index even ifTrue:[
cg@2015
  1052
                                    el isString ifTrue:[    
cg@2015
  1053
                                        resourceKeys add:el.
cg@2015
  1054
                                    ]
cg@2015
  1055
                                ].
cg@2015
  1056
                            ].
cg@2015
  1057
                        ] ifFalse:[
cg@2015
  1058
                            Transcript 
cg@2015
  1059
                                showCR:(resources 
cg@2015
  1060
                                        string:'Cannot derive resourceKey from non-array in %1 in %2'
cg@2015
  1061
                                        with:argNode formattedCode
cg@2015
  1062
                                        with:aMethod selector).
cg@2015
  1063
                        ].
cg@2015
  1064
                    ] ifFalse:[
cg@2015
  1065
                        Transcript 
cg@2015
  1066
                            showCR:(resources 
cg@2015
  1067
                                        string:'Cannot derive resourceKey from non-literal: %1 in %2'
cg@2015
  1068
                                        with:argNode formattedCode
cg@2015
  1069
                                        with:aMethod selector).
cg@2015
  1070
                    ].
cg@2015
  1071
                ].
cg@2015
  1072
                aNode
cg@2015
  1073
            ].
cg@2015
  1074
cg@2015
  1075
    matcher executeTree: parseTree initialAnswer: nil.
cg@2015
  1076
    ^ resourceKeys
cg@2015
  1077
!
cg@2015
  1078
cg@2015
  1079
extractTranslationsFromMenuSpecMethod:aMethod
cg@2015
  1080
    |menu resourceKeys|
cg@2015
  1081
cg@2015
  1082
    menu := aMethod mclass theNonMetaclass perform:aMethod selector.
cg@2015
  1083
    menu isNil ifTrue:[ ^ #() ].
cg@2015
  1084
cg@2015
  1085
    (menu isKindOf:Menu) ifFalse:[
cg@2015
  1086
        menu := Menu new fromLiteralArrayEncoding:menu
cg@2015
  1087
    ].
cg@2015
  1088
cg@2015
  1089
    resourceKeys := Set new.
cg@2015
  1090
    menu allItemsDo:[:aMenuItem |
cg@2015
  1091
        aMenuItem translateLabel ifTrue:[
cg@2015
  1092
            aMenuItem isSeparatorItem ifFalse:[
cg@2015
  1093
                resourceKeys add:aMenuItem label.
cg@2015
  1094
            ]
cg@2015
  1095
        ]
cg@2015
  1096
    ].
cg@2015
  1097
    ^ resourceKeys
cg@2015
  1098
!
cg@2015
  1099
cg@2015
  1100
extractTranslationsFromMethod:aMethod
cg@2015
  1101
    |mResources|
cg@2015
  1102
cg@2015
  1103
    mResources := aMethod resources.
cg@2015
  1104
    mResources notNil ifTrue:[
cg@2015
  1105
        (mResources includesKey:#menu) ifTrue:[
cg@2015
  1106
             ^ self extractTranslationsFromMenuSpecMethod:aMethod.
cg@2015
  1107
        ].
cg@2015
  1108
        (mResources includesKey:#canvas) ifTrue:[
cg@2015
  1109
             ^ self extractTranslationsFromUISpecMethod:aMethod.
cg@2015
  1110
        ].
cg@2015
  1111
        (mResources includesKey:#help) ifTrue:[
cg@2015
  1112
             ^ self extractTranslationsFromHelpSpecMethod:aMethod.
cg@2015
  1113
        ].
cg@2015
  1114
        (mResources includesKey:#tableColumns) ifTrue:[
cg@2015
  1115
             ^ self extractTranslationsFromTableColumnsSpecMethod:aMethod.
cg@2015
  1116
        ].
cg@2015
  1117
cg@2015
  1118
        ^ self extractTranslationsFromSpecMethod:aMethod.
cg@2015
  1119
    ].
cg@2015
  1120
    ^ self extractTranslationsFromMethodsCode:aMethod
cg@2015
  1121
!
cg@2015
  1122
cg@2015
  1123
extractTranslationsFromMethodsCode:aMethod
cg@2015
  1124
"/method:mthd selector:sel inClass:cls matchesParseTreeMatcher:aMatcher
cg@2015
  1125
    |codeStrings matcher parseTree resourceKeys|
cg@2015
  1126
cg@2015
  1127
    parseTree := RBParser 
cg@2015
  1128
            parseMethod:aMethod source 
cg@2015
  1129
            onError: [:str :pos | Transcript showCR:str. Transcript showCR:pos.
cg@2015
  1130
                                  nil].
cg@2015
  1131
    parseTree isNil ifTrue:[^ #() ].
cg@2015
  1132
cg@2015
  1133
    codeStrings  := 
cg@2015
  1134
        #(
cg@2015
  1135
                'resources `@msg: `@args'
cg@2015
  1136
                'self resources `@msg: `@args'
cg@2015
  1137
                'self class resources `@msg: `@args'
cg@2015
  1138
                'self classResources `@msg: `@args'
cg@2015
  1139
        ).
cg@2015
  1140
cg@2015
  1141
    resourceKeys := Set new.
cg@2015
  1142
cg@2015
  1143
    matcher := ParseTreeSearcher new.
cg@2015
  1144
    matcher 
cg@2015
  1145
        matchesAnyOf: codeStrings 
cg@2015
  1146
        do: [:aNode :answer |
cg@2015
  1147
                |sel keyStringArgNode keyStringArg|
cg@2015
  1148
cg@2015
  1149
                sel := aNode selector.
cg@2015
  1150
                ((sel startsWith:'string:') or:[(sel startsWith:'at:')]) ifTrue:[
cg@2015
  1151
                    keyStringArgNode := aNode arguments at:1.
cg@2015
  1152
                    keyStringArgNode isLiteral ifTrue:[
cg@2015
  1153
                        keyStringArg := keyStringArgNode value.
cg@2015
  1154
                        keyStringArg isString ifTrue:[
cg@2015
  1155
                            resourceKeys add:keyStringArg.
cg@2015
  1156
                        ] ifFalse:[
cg@2015
  1157
                            Transcript 
cg@2015
  1158
                                showCR:(resources 
cg@2015
  1159
                                        string:'Cannot derive resourceKey from non-string: %1 in %2'
cg@2015
  1160
                                        with:keyStringArgNode formattedCode
cg@2015
  1161
                                        with:aMethod selector).
cg@2015
  1162
                        ].
cg@2015
  1163
                    ] ifFalse:[
cg@2015
  1164
                        Transcript 
cg@2015
  1165
                            showCR:(resources 
cg@2015
  1166
                                        string:'Cannot derive resourceKey from non-literal: %1 in %2'
cg@2015
  1167
                                        with:keyStringArgNode formattedCode
cg@2015
  1168
                                        with:aMethod selector).
cg@2015
  1169
                    ].
cg@2015
  1170
                ].
cg@2015
  1171
                aNode
cg@2015
  1172
            ].
cg@2015
  1173
cg@2015
  1174
    matcher executeTree: parseTree initialAnswer: nil.
cg@2015
  1175
    ^ resourceKeys
cg@2015
  1176
!
cg@2015
  1177
cg@2015
  1178
extractTranslationsFromSpecMethod:aMethod
cg@2015
  1179
    ^ #()
cg@2015
  1180
!
cg@2015
  1181
cg@2015
  1182
extractTranslationsFromTableColumnsSpecMethod:aMethod
cg@2015
  1183
    |columnDescription resourceKeys|
cg@2015
  1184
cg@2015
  1185
    columnDescription := aMethod mclass theNonMetaclass perform:aMethod selector.
cg@2015
  1186
    columnDescription isNil ifTrue:[ ^ #() ].
cg@2015
  1187
cg@2015
  1188
    (columnDescription first isKindOf:DataSetColumnSpec) ifFalse:[
cg@2015
  1189
        columnDescription := columnDescription collect:[:el | DataSetColumnSpec new fromLiteralArrayEncoding:el].
cg@2015
  1190
    ].
cg@2015
  1191
cg@2015
  1192
    resourceKeys := Set new.
cg@2015
  1193
    columnDescription do:[:aColumnSpec |
cg@2015
  1194
        aColumnSpec translateLabel ifTrue:[
cg@2015
  1195
            resourceKeys add:aColumnSpec label.
cg@2015
  1196
        ]
cg@2015
  1197
    ].
cg@2015
  1198
    ^ resourceKeys
cg@2015
  1199
!
cg@2015
  1200
cg@2015
  1201
extractTranslationsFromUISpecMethod:aMethod
cg@2015
  1202
    |spec resourceKeys visitor|
cg@2015
  1203
cg@2015
  1204
    spec := aMethod mclass theNonMetaclass perform:aMethod selector.
cg@2015
  1205
    spec isNil ifTrue:[ ^ #() ].
cg@2015
  1206
cg@2015
  1207
    (spec isKindOf:UISpecification) ifFalse:[
cg@2015
  1208
        spec := UISpecification from:spec
cg@2015
  1209
    ].
cg@2015
  1210
cg@2015
  1211
    resourceKeys := Set new.
cg@2015
  1212
cg@2015
  1213
    visitor := UISpecVisitor new.
cg@2015
  1214
    spec acceptVisitor:visitor.
cg@2015
  1215
cg@2015
  1216
    ^ visitor translatedLabels
cg@2015
  1217
! !
cg@2015
  1218
cg@2015
  1219
!InternationalLanguageTranslationEditor methodsFor:'queries'!
cg@2015
  1220
cg@2015
  1221
hasUnsavedChanges
cg@2015
  1222
    ^ modified
cg@2015
  1223
! !
cg@2015
  1224
cg@2015
  1225
!InternationalLanguageTranslationEditor methodsFor:'specs-dynamic'!
cg@2015
  1226
cg@2015
  1227
columnInRow:row at:colIndex
cg@2015
  1228
    |lang|
cg@2015
  1229
cg@2015
  1230
    lang := self languageAtCol:colIndex.
cg@2015
  1231
    ^ row atLanguage:lang
cg@2015
  1232
!
cg@2015
  1233
cg@2015
  1234
getBackgroundForRow:row rowNr:rowNr col:colIndex
cg@2015
  1235
    |lang|
cg@2015
  1236
cg@2015
  1237
    colIndex == 1 ifTrue:[^ nil].
cg@2015
  1238
    lang := self languageAtCol:colIndex.
cg@2015
  1239
    ^ (row atLanguage:lang) isNil ifTrue:[Color red lightened] ifFalse:nil
cg@2015
  1240
!
cg@2015
  1241
cg@2015
  1242
keyStringAndLanguageSelectionTableColumnDescription
cg@2015
  1243
    |spec|
cg@2015
  1244
cg@2015
  1245
    spec := OrderedCollection new.
cg@2015
  1246
cg@2047
  1247
    spec add:(self class keyTableColumn first).
cg@2015
  1248
cg@2015
  1249
    self shownLanguages do:[:lang |
cg@2015
  1250
        |entry|
cg@2015
  1251
cg@2047
  1252
        entry := self class languageTableColumn first.
cg@2047
  1253
        entry := entry copy replaceAll:#lang with:lang.
cg@2015
  1254
        spec add: entry 
cg@2015
  1255
    ].
cg@2015
  1256
    ^ spec
cg@2015
  1257
!
cg@2015
  1258
cg@2015
  1259
keyStringInRow:row
cg@2015
  1260
    ^ row keyString
cg@2015
  1261
! !
cg@2015
  1262
cg@2015
  1263
!InternationalLanguageTranslationEditor methodsFor:'user actions'!
cg@2015
  1264
cg@2015
  1265
selectionChanged
cg@2015
  1266
    |rowSelectionIndex colSelectionIndex language selectedKey originalText languageText
cg@2048
  1267
     answer newText autoAccept|
cg@2048
  1268
cg@2048
  1269
    autoAccept := true.
cg@2048
  1270
cg@2048
  1271
    self originalTextModifiedHolder value ifTrue:[ 
cg@2048
  1272
        answer := OptionBox 
cg@2048
  1273
                      request:'Accept changed original text (key) ?' 
cg@2048
  1274
                      label:'Original text (key) changed'
cg@2048
  1275
                      image:(WarningBox iconBitmap)
cg@2048
  1276
                      buttonLabels:#('Cancel' 'Accept' 'Accept As New')
cg@2048
  1277
                      values:#(nil #accept #acceptAsNew)
cg@2048
  1278
                      default:#acceptAsNew.
cg@2048
  1279
cg@2048
  1280
        answer isNil ifTrue:[^ self ].
cg@2048
  1281
        answer == #accept ifTrue:[
cg@2048
  1282
self halt.        ].
cg@2048
  1283
        answer == #acceptAsNew ifTrue:[
cg@2048
  1284
self halt.        ].
cg@2048
  1285
    ].
cg@2048
  1286
    self languageTextModifiedHolder value ifTrue:[ 
cg@2048
  1287
        (autoAccept or:[Dialog confirm:'Accept changed translation ?']) ifTrue:[
cg@2048
  1288
            languageTextAcceptHolder value:true.
cg@2048
  1289
self halt.
cg@2048
  1290
            lastLanguage notNil ifTrue:[
cg@2048
  1291
                newText := self languageTextHolder value asCollectionOfLines first.
cg@2048
  1292
                keyStringsToLanguageMappings at:lastSelectedKey language:lastLanguage put:newText.
cg@2048
  1293
            ]
cg@2048
  1294
        ]
cg@2048
  1295
    ].
cg@2015
  1296
cg@2015
  1297
    colSelectionIndex := dataSetView selectedColIndex.
cg@2015
  1298
    language := colSelectionIndex > 1 ifTrue:[ shownLanguages at:colSelectionIndex-1 ] ifFalse:nil.
cg@2015
  1299
cg@2015
  1300
    rowSelectionIndex := self selectedKeyRow value.
cg@2015
  1301
    rowSelectionIndex ~~ 0 ifTrue:[
cg@2015
  1302
        selectedKey := keyStringsToLanguageMappings keyAt:rowSelectionIndex.
cg@2015
  1303
        originalText := selectedKey storeString.
cg@2015
  1304
        language notNil ifTrue:[
cg@2015
  1305
            languageText := keyStringsToLanguageMappings at:selectedKey language:language.
cg@2015
  1306
            languageText notNil ifTrue:[
cg@2015
  1307
                languageText := languageText storeString.
cg@2015
  1308
            ]
cg@2015
  1309
        ]
cg@2015
  1310
    ].
cg@2015
  1311
cg@2015
  1312
    self originalTextHolder value:originalText.
cg@2015
  1313
    self languageTextHolder value:languageText.
cg@2015
  1314
cg@2015
  1315
    self originalTextModifiedHolder value:false.
cg@2015
  1316
    self languageTextModifiedHolder value:false.
cg@2048
  1317
cg@2048
  1318
    lastLanguage := language.
cg@2048
  1319
    lastSelectedKey := selectedKey.
cg@2015
  1320
!
cg@2015
  1321
cg@2015
  1322
shownLanguagesChanged
cg@2015
  1323
    self keyStringAndLanguageSelectionTableColumnDescriptionHolder 
cg@2015
  1324
        value:(self keyStringAndLanguageSelectionTableColumnDescription).
cg@2015
  1325
!
cg@2015
  1326
cg@2015
  1327
stopApplication
cg@2015
  1328
    |p|
cg@2015
  1329
cg@2015
  1330
    (p := monitoredApplication) notNil ifTrue:[
cg@2015
  1331
        p terminate.
cg@2015
  1332
    ].
cg@2015
  1333
! !
cg@2015
  1334
cg@2015
  1335
!InternationalLanguageTranslationEditor::AccessCollectingPseudoResourcePack methodsFor:'accessing'!
cg@2015
  1336
cg@2015
  1337
realResourcePack:something
cg@2015
  1338
    realResourcePack := something.
cg@2015
  1339
! !
cg@2015
  1340
cg@2015
  1341
!InternationalLanguageTranslationEditor::KeyStringsToLanguageMappings class methodsFor:'instance creation'!
cg@2015
  1342
cg@2015
  1343
new
cg@2015
  1344
    ^ self basicNew initialize
cg@2015
  1345
! !
cg@2015
  1346
cg@2015
  1347
!InternationalLanguageTranslationEditor::KeyStringsToLanguageMappings methodsFor:'accessing'!
cg@2015
  1348
cg@2015
  1349
addKey:aKey
cg@2031
  1350
    (keys includes:aKey) ifFalse:[
cg@2031
  1351
        keys add:aKey.
cg@2031
  1352
        self changed.
cg@2031
  1353
    ]
cg@2015
  1354
!
cg@2015
  1355
cg@2015
  1356
addKeys:aCollectionOfKey
cg@2015
  1357
    keys addAll:aCollectionOfKey.
cg@2015
  1358
    self changed.
cg@2015
  1359
!
cg@2015
  1360
cg@2015
  1361
addLanguage:lang
cg@2031
  1362
    (languages includes:lang) ifFalse:[
cg@2031
  1363
        languages add:lang.
cg@2032
  1364
        perLanguageMappings at:lang put:(Dictionary new).
cg@2031
  1365
    ]
cg@2015
  1366
!
cg@2015
  1367
cg@2015
  1368
at:aKey language:language
cg@2032
  1369
    ^ (perLanguageMappings at:language) at:aKey ifAbsent:nil
cg@2015
  1370
!
cg@2015
  1371
cg@2015
  1372
at:aKey language:language put:value
cg@2015
  1373
    self addKey:aKey.
cg@2032
  1374
    ^ (perLanguageMappings at:language) at:aKey put:value
cg@2015
  1375
!
cg@2015
  1376
cg@2015
  1377
keyAt:index
cg@2015
  1378
    ^ keys at:index.
cg@2015
  1379
!
cg@2015
  1380
cg@2015
  1381
keyAt:index ifAbsent:exceptionalValue
cg@2015
  1382
    ^ keys at:index ifAbsent:exceptionalValue.
cg@2015
  1383
!
cg@2015
  1384
cg@2015
  1385
keys
cg@2015
  1386
    ^ keys
cg@2015
  1387
!
cg@2015
  1388
cg@2015
  1389
languages
cg@2015
  1390
    ^ languages
cg@2015
  1391
!
cg@2015
  1392
cg@2015
  1393
removeKey:aKey
cg@2015
  1394
    keys remove:aKey ifAbsent:[].
cg@2032
  1395
    perLanguageMappings do:[:eachMapping |
cg@2015
  1396
        eachMapping removeKey:aKey ifAbsent:[].
cg@2015
  1397
    ].
cg@2015
  1398
    self changed.
cg@2015
  1399
!
cg@2015
  1400
cg@2015
  1401
size
cg@2015
  1402
    ^ keys size
cg@2015
  1403
! !
cg@2015
  1404
cg@2015
  1405
!InternationalLanguageTranslationEditor::KeyStringsToLanguageMappings methodsFor:'enumerating'!
cg@2015
  1406
cg@2015
  1407
do:aBlock
cg@2015
  1408
    keys do:[:eachKey |
cg@2015
  1409
        aBlock value:(InternationalLanguageTranslationEditor::LanguageMappingRow new 
cg@2015
  1410
                                key:eachKey; mappings:self).
cg@2015
  1411
    ].
cg@2015
  1412
! !
cg@2015
  1413
cg@2015
  1414
!InternationalLanguageTranslationEditor::KeyStringsToLanguageMappings methodsFor:'initialization'!
cg@2015
  1415
cg@2015
  1416
initialize
cg@2015
  1417
    super initialize.
cg@2015
  1418
cg@2015
  1419
    keys := OrderedSet new.
cg@2015
  1420
    languages := OrderedCollection new.
cg@2032
  1421
    perLanguageMappings := Dictionary new.
cg@2032
  1422
    perLanguageInfo := Dictionary new.
cg@2015
  1423
cg@2031
  1424
    self addLanguage:#'de'.
cg@2031
  1425
    self addLanguage:#'fr'.
cg@2031
  1426
    self addLanguage:#'es'.
cg@2031
  1427
    self addLanguage:(Smalltalk language).
cg@2031
  1428
cg@2031
  1429
    "/ self initializeDemoMappings.
cg@2031
  1430
!
cg@2031
  1431
cg@2031
  1432
initializeDemoMappings
cg@2015
  1433
    keys add:'open'.
cg@2015
  1434
    keys add:'close'.
cg@2015
  1435
    keys add:'yes'.
cg@2015
  1436
    keys add:'no'.
cg@2015
  1437
cg@2015
  1438
    self addLanguage:#'de'.
cg@2015
  1439
    self addLanguage:#'fr'.
cg@2015
  1440
cg@2015
  1441
    self at:'open' language:#'de' put:'öffnen'.    
cg@2015
  1442
    self at:'close' language:#'de' put:'schliessen'.    
cg@2015
  1443
    self at:'yes' language:#'de' put:'ja'.    
cg@2015
  1444
    self at:'no' language:#'de' put:'nein'.    
cg@2015
  1445
    self at:'cancel' language:#'de' put:'abbrechen'.    
cg@2015
  1446
cg@2015
  1447
    self at:'open' language:#'fr' put:'ouvrir'.    
cg@2015
  1448
    self at:'close' language:#'fr' put:'fermer'.    
cg@2015
  1449
    self at:'yes' language:#'fr' put:'oui'.    
cg@2015
  1450
    self at:'no' language:#'fr' put:'non'.    
cg@2015
  1451
! !
cg@2015
  1452
cg@2015
  1453
!InternationalLanguageTranslationEditor::KeyStringsToLanguageMappings methodsFor:'private'!
cg@2015
  1454
cg@2015
  1455
atLanguage:lang
cg@2032
  1456
    ^ perLanguageMappings at:lang
cg@2015
  1457
!
cg@2015
  1458
cg@2015
  1459
atLanguageIndex:idx
cg@2015
  1460
    |lang|
cg@2015
  1461
cg@2015
  1462
    lang := languages at:idx.
cg@2015
  1463
    ^ self atLanguage:lang.
cg@2032
  1464
!
cg@2032
  1465
cg@2032
  1466
mappingAtLanguage:lang
cg@2032
  1467
    ^ perLanguageMappings at:lang
cg@2032
  1468
!
cg@2032
  1469
cg@2032
  1470
mappingAtLanguageIndex:idx
cg@2032
  1471
    |lang|
cg@2032
  1472
cg@2032
  1473
    lang := languages at:idx.
cg@2032
  1474
    ^ self mappingAtLanguage:lang.
cg@2015
  1475
! !
cg@2015
  1476
cg@2015
  1477
!InternationalLanguageTranslationEditor::KeyStringsToLanguageMappings methodsFor:'queries'!
cg@2015
  1478
cg@2015
  1479
includesKey:aKey
cg@2015
  1480
    ^ keys includes:aKey
cg@2015
  1481
!
cg@2015
  1482
cg@2015
  1483
includesLanguage:lang
cg@2015
  1484
    ^ languages includes:lang
cg@2015
  1485
!
cg@2015
  1486
cg@2015
  1487
indexOfKey:aKey
cg@2015
  1488
    ^ keys indexOf:aKey
cg@2015
  1489
! !
cg@2015
  1490
cg@2015
  1491
!InternationalLanguageTranslationEditor::LanguageMappingRow methodsFor:'accessing'!
cg@2015
  1492
cg@2015
  1493
atLanguage:language
cg@2032
  1494
    |translation|
cg@2032
  1495
cg@2032
  1496
    translation := (mappings mappingAtLanguage:language) at:key ifAbsent:nil.
cg@2032
  1497
    ^ translation isNil ifTrue:nil ifFalse:[translation printString]
cg@2015
  1498
!
cg@2015
  1499
cg@2015
  1500
columnAt:columnNr
cg@2032
  1501
    ^ (mappings mappingAtLanguageIndex:columnNr-1) at: key ifAbsent:nil
cg@2015
  1502
!
cg@2015
  1503
cg@2015
  1504
key:something
cg@2015
  1505
    key := something.
cg@2015
  1506
!
cg@2015
  1507
cg@2015
  1508
keyString
cg@2032
  1509
    ^ key printString
cg@2015
  1510
!
cg@2015
  1511
cg@2015
  1512
mappings:something
cg@2015
  1513
    mappings := something.
cg@2015
  1514
! !
cg@2015
  1515
cg@2015
  1516
!InternationalLanguageTranslationEditor::UISpecVisitor methodsFor:'accessing'!
cg@2015
  1517
cg@2015
  1518
translatedLabels
cg@2015
  1519
    ^ translatedLabels ? #()
cg@2015
  1520
! !
cg@2015
  1521
cg@2015
  1522
!InternationalLanguageTranslationEditor::UISpecVisitor methodsFor:'visiting'!
cg@2015
  1523
cg@2015
  1524
visitObject:anObject with:aParameter
cg@2033
  1525
    |l|
cg@2033
  1526
cg@2015
  1527
    (anObject isKindOf:UISpecification) ifTrue:[
cg@2015
  1528
        (anObject respondsTo:#translateLabel) ifTrue:[
cg@2015
  1529
            anObject translateLabel == true ifTrue:[
cg@2015
  1530
                translatedLabels isNil ifTrue:[
cg@2015
  1531
                    translatedLabels := Set new.
cg@2015
  1532
                ].
cg@2033
  1533
                l := anObject perform:#label ifNotUnderstood:nil.
cg@2033
  1534
                l notNil ifTrue:[
cg@2033
  1535
                    translatedLabels add:l.
cg@2033
  1536
                ].
cg@2015
  1537
            ].
cg@2015
  1538
        ].
cg@2015
  1539
    ].
cg@2015
  1540
    self visitChildrenOf:anObject.
cg@2015
  1541
! !
cg@2015
  1542
cg@2015
  1543
!InternationalLanguageTranslationEditor class methodsFor:'documentation'!
cg@2015
  1544
cg@2015
  1545
version
cg@2015
  1546
    ^ '$Header$'
cg@2015
  1547
! !