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