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