#FEATURE by cg
class: Tools::InternationalLanguageTranslationEditor
added:
#beUnmodified
#selectKey:
comment/format in: #searchForSimilarTranslation
changed:
#hasUnsavedChanges
#selectedKey
category of: #searchForSimilarTranslation
class: Tools::InternationalLanguageTranslationEditor class
comment/format in: #openOnFile:
changed: #openOnPackage:
--- a/Tools__InternationalLanguageTranslationEditor.st Wed Feb 20 12:22:37 2019 +0100
+++ b/Tools__InternationalLanguageTranslationEditor.st Wed Feb 20 13:14:38 2019 +0100
@@ -1024,29 +1024,33 @@
!InternationalLanguageTranslationEditor class methodsFor:'startup'!
openOnFile:aFilename
- |fn editor|
+ "opens an editor on a single resources file; returns the editor"
+
+ |fn|
fn := aFilename asFilename.
- ^ (editor := self new)
+ ^ self new
allButOpen;
readResourceFile:fn asLanguage:(fn withoutSuffix baseName);
+ beUnmodified;
openWindow;
yourself.
- "Modified: / 20-02-2019 / 12:06:24 / Claus Gittinger"
+ "Modified: / 20-02-2019 / 12:36:13 / Claus Gittinger"
!
openOnPackage:aPackageId
- |editor|
-
- ^ (editor := self new)
+ "opens an editor on all languages of a package; returns the editor"
+
+ ^ self new
allButOpen;
readResourceFileForPackage:aPackageId language:#all;
+ beUnmodified;
openWindow;
yourself.
- "Modified: / 20-02-2019 / 12:20:59 / Claus Gittinger"
+ "Modified: / 20-02-2019 / 12:36:18 / Claus Gittinger"
! !
!InternationalLanguageTranslationEditor class methodsFor:'tableColumns specs'!
@@ -1101,6 +1105,12 @@
!InternationalLanguageTranslationEditor methodsFor:'accessing'!
+beUnmodified
+ modified := false.
+
+ "Created: / 20-02-2019 / 12:36:03 / Claus Gittinger"
+!
+
currentSelectionIndex
^ self selectedKeyRow value
@@ -1137,6 +1147,21 @@
"Modified: / 25-10-2018 / 16:25:08 / Claus Gittinger"
!
+selectKey:aKey
+ "selects aKey if there is a corresponding row"
+
+ | index |
+
+ keyStringsToLanguageMappings isNil ifTrue:[^false].
+ index := keyStringsToLanguageMappings keys indexOf:aKey.
+ index == 0 ifTrue:[^ false].
+
+ self selectedKeyRow value:index.
+ ^ true
+
+ "Created: / 20-02-2019 / 12:31:01 / Claus Gittinger"
+!
+
selectListIndex: rowIndex
"/ |selection list|
"/ list := self objectsList.
@@ -1154,10 +1179,12 @@
| rowSelectionIndex |
keyStringsToLanguageMappings isNil ifTrue:[^nil].
- self selectedKeyRow value isNil ifTrue:[^nil].
- rowSelectionIndex := self selectedKeyRow value.
+ (rowSelectionIndex := self selectedKeyRow value) isNil ifTrue:[^nil].
rowSelectionIndex == 0 ifTrue:[^nil].
+
^ keyStringsToLanguageMappings keyAt:rowSelectionIndex.
+
+ "Modified: / 20-02-2019 / 12:28:18 / Claus Gittinger"
!
tableView
@@ -1167,36 +1194,6 @@
"Created: / 15-06-2007 / 18:59:51 / Administrador"
! !
-!InternationalLanguageTranslationEditor methodsFor:'additionalFunctionalities'!
-
-searchForSimilarTranslation
- "Looks for a quite similar translation for the key and display a dialog with available options"
-
- |similarTranslationsAssociations selectedTranslation key|
-
- self shouldSearchForSimilarTranslation ifFalse:[^self].
-
- key := self selectedKey.
- key isNil ifTrue:[^ self.].
- similarTranslationsAssociations := keyStringsToLanguageMappings searchForSimilarTranslation: key in: self currentLanguage.
- similarTranslationsAssociations isEmpty ifTrue:[^self].
-
- similarTranslationsAssociations := similarTranslationsAssociations associations inject: OrderedCollection new into:[:collection :association |
- collection detect:[:selectedAssociation |
- selectedAssociation value sameAs: association value] ifNone:[collection add: association].
- collection].
- selectedTranslation := Dialog
- choose:'Choose one if you consider it´s usefull to translate:
- ',
- '<', key, '> ', (self currentExampleLanguageText ifNil:[''])
- fromList: (similarTranslationsAssociations collect:[:each | '<', each key, '> ', each value])
- values: (similarTranslationsAssociations collect:[:each | each value])
- lines:10
- cancel: nil.
-
- selectedTranslation notNil ifTrue:[self languageTextHolderValue: selectedTranslation].
-! !
-
!InternationalLanguageTranslationEditor methodsFor:'aspects'!
alwaysWriteUTF8Holder
@@ -2776,7 +2773,9 @@
!
hasUnsavedChanges
- ^ modified
+ ^ modified ? false
+
+ "Modified: / 20-02-2019 / 12:33:42 / Claus Gittinger"
!
includesKey: aKey
@@ -2980,6 +2979,37 @@
"Created: / 16-06-2007 / 09:33:33 / Administrador"
!
+searchForSimilarTranslation
+ "Looks for a quite similar translation for the key and display a dialog with available options"
+
+ |similarTranslationsAssociations selectedTranslation key|
+
+ self shouldSearchForSimilarTranslation ifFalse:[^self].
+
+ key := self selectedKey.
+ key isNil ifTrue:[^ self.].
+
+ similarTranslationsAssociations := keyStringsToLanguageMappings searchForSimilarTranslation: key in: self currentLanguage.
+ similarTranslationsAssociations isEmpty ifTrue:[^self].
+
+ similarTranslationsAssociations := similarTranslationsAssociations associations inject: OrderedCollection new into:[:collection :association |
+ collection detect:[:selectedAssociation |
+ selectedAssociation value sameAs: association value] ifNone:[collection add: association].
+ collection].
+ selectedTranslation := Dialog
+ choose:'Choose one if you consider it´s usefull to translate:
+ ',
+ '<', key, '> ', (self currentExampleLanguageText ifNil:[''])
+ fromList: (similarTranslationsAssociations collect:[:each | '<', each key, '> ', each value])
+ values: (similarTranslationsAssociations collect:[:each | each value])
+ lines:10
+ cancel: nil.
+
+ selectedTranslation notNil ifTrue:[self languageTextHolderValue: selectedTranslation].
+
+ "Modified (format): / 20-02-2019 / 12:27:41 / Claus Gittinger"
+!
+
searchNextText
self searchNextTextIncludingCurrentSelection: false.