#FEATURE by cg draft
authorClaus Gittinger <cg@exept.de>
Fri, 22 Feb 2019 09:51:13 +0100
changeset 3642 9b49ded14b95
parent 3641 507f252953da
child 3643 c3d51a2ffb18
#FEATURE by cg class: Tools::InternationalLanguageTranslationEditor added: #addTranslationForKey: #selectOrAddKey: changed: #addTranslation class: Tools::InternationalLanguageTranslationEditor class changed: #windowSpec
Tools__InternationalLanguageTranslationEditor.st
--- a/Tools__InternationalLanguageTranslationEditor.st	Wed Feb 20 13:14:38 2019 +0100
+++ b/Tools__InternationalLanguageTranslationEditor.st	Fri Feb 22 09:51:13 2019 +0100
@@ -319,7 +319,7 @@
     ^ 
     #(FullSpec
        name: windowSpec
-       uuid: '37d7f37a-b8d0-11e8-aeef-b8f6b1108e05'
+       uuid: 'ba9bc312-367b-11e9-8e9b-b8f6b1108e05'
        window: 
       (WindowSpec
          label: 'InternationalLanguageTranslationEditor'
@@ -462,9 +462,17 @@
                                postBuildCallback: languageEditorBuilt:
                              )
                             (ActionButtonSpec
+                               label: 'Add'
+                               name: 'Button2'
+                               layout: (LayoutFrame -344 0.83085250338295003 0 0 -255 0.83085250338295003 27 0)
+                               uuid: '37d809fa-b8d0-11e8-aeef-b8f6b1108e05'
+                               translateLabel: true
+                               model: addTranslationEntry
+                             )
+                            (ActionButtonSpec
                                label: 'Paste Original'
                                name: 'Button1'
-                               layout: (LayoutFrame -186 0.83085250338295003 0 0 -64 0.83085250338295003 27 0)
+                               layout: (LayoutFrame -202 0.83085250338295003 0 0 -71 0.83085250338295003 27 0)
                                uuid: '37d809fa-b8d0-11e8-aeef-b8f6b1108e05'
                                translateLabel: true
                                model: pasteOriginalInLanguageText
@@ -474,7 +482,7 @@
                             (ActionButtonSpec
                                label: 'Paste Previous'
                                name: 'pastePreviousTranslation'
-                               layout: (LayoutFrame -42 0.83085250338295003 0 0 118 0.83085250338295003 27 0)
+                               layout: (LayoutFrame -66 0.83085250338295003 0 0 127 0.83085250338295003 27 0)
                                uuid: '37d80b80-b8d0-11e8-aeef-b8f6b1108e05'
                                translateLabel: true
                                model: pastePreviousTranslationInLanguageText
@@ -1173,6 +1181,19 @@
     "Modified: / 22-06-2007 / 13:45:54 / Administrador"
 !
 
+selectOrAddKey:aKey
+    "selects aKey if there is a corresponding row,
+     otherwise fills in the fields for editing"
+
+    (self selectKey:aKey) ifFalse:[
+        self addTranslationForKey:aKey.
+        self languageTextHolder value:aKey.
+    ].
+
+    "Created: / 21-02-2019 / 17:09:36 / Claus Gittinger"
+    "Modified: / 22-02-2019 / 09:25:43 / Claus Gittinger"
+!
+
 selectedKey
     "Returns the current selected key if there is one row seleted. Otherwise, returns nil"
 
@@ -1745,19 +1766,29 @@
 !
 
 addTranslation
-    |key index|
+    |key|
 
     key := Dialog request:'New Key:'.
     key isEmptyOrNil ifTrue:[^self].
-
-    (self includesKey:key) ifFalse:[
-        keyStringsToLanguageMappings addKey:key.
+    
+    self addTranslationForKey:key
+
+    "Modified: / 22-02-2019 / 09:25:17 / Claus Gittinger"
+!
+
+addTranslationForKey:newKey
+    |index|
+
+    newKey isEmptyOrNil ifTrue:[^self].
+
+    (self includesKey:newKey) ifFalse:[
+        keyStringsToLanguageMappings addKey:newKey.
         modified := true.
     ].
-   index := keyStringsToLanguageMappings indexOfKey:key.
-   self selectedKeyRow value:index
-
-    "Modified: / 25-10-2018 / 16:16:21 / Claus Gittinger"
+   index := keyStringsToLanguageMappings indexOfKey:newKey.
+   self selectedKeyRow value:index.
+
+    "Created: / 22-02-2019 / 09:24:59 / Claus Gittinger"
 !
 
 browseReferringMethods