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