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