#UI_ENHANCEMENT by cg draft
authorClaus Gittinger <cg@exept.de>
Wed, 20 Feb 2019 12:22:37 +0100
changeset 3640 278e1952a646
parent 3639 e8a2e6f41121
child 3641 507f252953da
#UI_ENHANCEMENT by cg class: Tools::InternationalLanguageTranslationEditor added: #readResourceFileForPackage:language: changed: #readResourceFileForPackage: class: Tools::InternationalLanguageTranslationEditor class changed: #openOnPackage:
Tools__InternationalLanguageTranslationEditor.st
--- a/Tools__InternationalLanguageTranslationEditor.st	Wed Feb 20 12:08:15 2019 +0100
+++ b/Tools__InternationalLanguageTranslationEditor.st	Wed Feb 20 12:22:37 2019 +0100
@@ -1042,11 +1042,11 @@
     
     ^ (editor := self new)
         allButOpen;
-        readResourceFileForPackage:aPackageId;
+        readResourceFileForPackage:aPackageId language:#all;
         openWindow;
         yourself.
 
-    "Modified: / 20-02-2019 / 12:06:33 / Claus Gittinger"
+    "Modified: / 20-02-2019 / 12:20:59 / Claus Gittinger"
 ! !
 
 !InternationalLanguageTranslationEditor class methodsFor:'tableColumns specs'!
@@ -2085,7 +2085,7 @@
 !
 
 readResourceFileForPackage:aPackage
-    |allLanguages lang packageDir resourceDir langFile|
+    |allLanguages lang packageDir resourceDir|
 
     packageDir := Smalltalk packageDirectoryForPackageId:aPackage.
     resourceDir := packageDir asFilename construct:'resources'.
@@ -2117,20 +2117,48 @@
         cancel:nil.
 
     lang isNil ifTrue:[^ self ].
-
-    langFile := resourceDir construct:lang,'.rs'.
-
-    lang == #all ifTrue:[
+    self readResourceFileForPackage:aPackage language:lang
+
+    "Modified: / 20-02-2019 / 12:20:35 / Claus Gittinger"
+!
+
+readResourceFileForPackage:aPackage language:lang
+    "lang may be a language (de, en) or #all"
+
+    |allLanguages packageDir resourceDir langFile|
+
+    packageDir := Smalltalk packageDirectoryForPackageId:aPackage.
+    resourceDir := packageDir asFilename construct:'resources'.
+    resourceDir exists ifFalse:[
+        Dialog information:'No resource directory present for package: ',aPackage.
+        ^ self
+    ].    
+
+    lang = #all ifTrue:[
+        allLanguages := Set new.
+        resourceDir directoryContentsAsFilenamesDo:[:eachFile |
+            eachFile suffix = 'rs' ifTrue:[
+                (('##.rs' match:eachFile baseName)
+                or:[('##-##.rs' match:eachFile baseName)]) ifTrue:[
+                    allLanguages add:(eachFile withoutSuffix baseName)
+                ].
+            ].
+        ].
+
+        allLanguages addAll:languagesList.
+        allLanguages := allLanguages asSortedCollection.
+
         allLanguages do:[:lang |
             self addLanguage:lang.
             self readResourceFile:(resourceDir construct:lang,'.rs') asLanguage:lang.
         ].
     ] ifFalse:[
+        langFile := resourceDir construct:lang,'.rs'.
         self readResourceFile:langFile asLanguage:lang asSymbol
     ].
     self window label:('%1: %2' bindWith:self class nameWithoutPrefix with:aPackage)
 
-    "Modified: / 20-02-2019 / 11:45:50 / Claus Gittinger"
+    "Created: / 20-02-2019 / 12:20:02 / Claus Gittinger"
 !
 
 removeLanguage