Tools__InternationalLanguageTranslationEditor.st
changeset 2031 85947c4c6502
parent 2015 8f226ff9b5e6
child 2032 cc2edbb9ebfc
equal deleted inserted replaced
2030:bef3cfda7e6a 2031:85947c4c6502
     8 		showMissingTranslationsOnly
     8 		showMissingTranslationsOnly
     9 		keyStringAndLanguageSelectionTableColumnDescriptionHolder
     9 		keyStringAndLanguageSelectionTableColumnDescriptionHolder
    10 		languageShownHolders dataSetView lastExtractedClass
    10 		languageShownHolders dataSetView lastExtractedClass
    11 		lastExtractedApplicationClass stopApplicationIconVisibleHolder
    11 		lastExtractedApplicationClass stopApplicationIconVisibleHolder
    12 		monitoredApplication originalTextModifiedHolder
    12 		monitoredApplication originalTextModifiedHolder
    13 		languageTextModifiedHolder'
    13 		languageTextModifiedHolder inSingleFileMode'
    14 	classVariableNames:'LastExtractedClass LastExtractedApplicationClass'
    14 	classVariableNames:'LastExtractedClass LastExtractedApplicationClass'
    15 	poolDictionaries:''
    15 	poolDictionaries:''
    16 	category:'Interface-UIPainter'
    16 	category:'Interface-UIPainter'
    17 !
    17 !
    18 
    18 
   549     super closeRequest
   549     super closeRequest
   550 !
   550 !
   551 
   551 
   552 initialize
   552 initialize
   553     modified := false.
   553     modified := false.
       
   554     inSingleFileMode := false.
   554     super initialize
   555     super initialize
   555 !
   556 !
   556 
   557 
   557 postBuildDataSet:aView
   558 postBuildDataSet:aView
   558     dataSetView := aView
   559     dataSetView := aView
   685     "/ directory, and open a viewer with:
   686     "/ directory, and open a viewer with:
   686     "/ HTMLDocumentView openFullOnDocumentationFile:'help/<MyApplication>/TOP.html'.
   687     "/ HTMLDocumentView openFullOnDocumentationFile:'help/<MyApplication>/TOP.html'.
   687 !
   688 !
   688 
   689 
   689 readResourceFile:aFilename
   690 readResourceFile:aFilename
   690     |inStream lineString|
   691     |lang|
       
   692 
       
   693     lang := Dialog choose:'For which language ?' fromList:languagesList lines:10.
       
   694     lang isNil ifTrue:[^ self ].
       
   695 
       
   696     self readResourceFile:aFilename asLanguage:lang asSymbol
       
   697 !
       
   698 
       
   699 readResourceFile:aFilename asLanguage:lang
       
   700     |resourcePack inStream lineString encoding decoder sortedKeys remainingKeys|
   691 
   701 
   692     aFilename exists ifFalse:[^ self ].
   702     aFilename exists ifFalse:[^ self ].
       
   703 
       
   704     resourcePack := ResourcePack new.
   693 
   705 
   694     inStream := aFilename readStream.
   706     inStream := aFilename readStream.
   695     [inStream atEnd] whileFalse:[
   707     [inStream atEnd] whileFalse:[
   696         lineString := inStream nextLine.
   708         lineString := inStream nextLine.
   697         (lineString notEmpty 
   709         (lineString notEmpty 
   698         and:[ (lineString startsWith:';') not ]) ifTrue:[
   710         and:[ (lineString startsWith:';') not ]) ifTrue:[
   699             (lineString startsWith:'#encoding ') ifTrue:[
   711             ((lineString startsWith:'#') and:[(lineString startsWith:'#(') not]) ifTrue:[
   700 self halt.
   712                 lineString := (lineString copyFrom:2) withoutSeparators.
       
   713                 (lineString startsWith:'encoding ') ifTrue:[
       
   714                     encoding := ResourcePack extractEncodingFromLine:lineString.
       
   715                     decoder := CharacterEncoder encoderFor:encoding ifAbsent:nil.
       
   716                 ].
   701             ] ifFalse:[
   717             ] ifFalse:[
   702 self halt.
   718                 ResourcePack
       
   719                     processResourceLine:lineString 
       
   720                     encoding:decoder 
       
   721                     file:aFilename pathName 
       
   722                     printErrorWith:[:msg | Transcript showCR:msg ] 
       
   723                     for:resourcePack
       
   724                     keepUselessTranslations:true.
   703             ].
   725             ].
   704         ].
   726         ].
   705     ].
   727     ].
   706     inStream close.
   728     inStream close.
       
   729 
       
   730     sortedKeys := (resourcePack keys select:[:k | k isString]) asSortedCollection.
       
   731     remainingKeys := resourcePack keys select:[:k | k isString not].
       
   732 
       
   733     sortedKeys do:[:k |
       
   734         keyStringsToLanguageMappings at:k language:lang put:(resourcePack at:k)
       
   735     ].
       
   736     remainingKeys do:[:k |
       
   737         keyStringsToLanguageMappings at:k language:lang put:(resourcePack at:k)
       
   738     ].
   707 !
   739 !
   708 
   740 
   709 removeLanguage
   741 removeLanguage
   710     "automatically generated by UIEditor ..."
   742     "automatically generated by UIEditor ..."
   711 
   743 
  1161 ! !
  1193 ! !
  1162 
  1194 
  1163 !InternationalLanguageTranslationEditor::KeyStringsToLanguageMappings methodsFor:'accessing'!
  1195 !InternationalLanguageTranslationEditor::KeyStringsToLanguageMappings methodsFor:'accessing'!
  1164 
  1196 
  1165 addKey:aKey
  1197 addKey:aKey
  1166     keys add:aKey.
  1198     (keys includes:aKey) ifFalse:[
  1167     self changed.
  1199         keys add:aKey.
       
  1200         self changed.
       
  1201     ]
  1168 !
  1202 !
  1169 
  1203 
  1170 addKeys:aCollectionOfKey
  1204 addKeys:aCollectionOfKey
  1171     keys addAll:aCollectionOfKey.
  1205     keys addAll:aCollectionOfKey.
  1172     self changed.
  1206     self changed.
  1173 !
  1207 !
  1174 
  1208 
  1175 addLanguage:lang
  1209 addLanguage:lang
  1176     languages add:lang.
  1210     (languages includes:lang) ifFalse:[
  1177     languageMappings at:lang put:(Dictionary new).
  1211         languages add:lang.
       
  1212         languageMappings at:lang put:(Dictionary new).
       
  1213     ]
  1178 !
  1214 !
  1179 
  1215 
  1180 at:aKey language:language
  1216 at:aKey language:language
  1181     ^ (languageMappings at:language) at:aKey ifAbsent:nil
  1217     ^ (languageMappings at:language) at:aKey ifAbsent:nil
  1182 !
  1218 !
  1230 
  1266 
  1231     keys := OrderedSet new.
  1267     keys := OrderedSet new.
  1232     languages := OrderedCollection new.
  1268     languages := OrderedCollection new.
  1233     languageMappings := Dictionary new.
  1269     languageMappings := Dictionary new.
  1234 
  1270 
       
  1271     self addLanguage:#'de'.
       
  1272     self addLanguage:#'fr'.
       
  1273     self addLanguage:#'es'.
       
  1274     self addLanguage:(Smalltalk language).
       
  1275 
       
  1276     "/ self initializeDemoMappings.
       
  1277 !
       
  1278 
       
  1279 initializeDemoMappings
  1235     keys add:'open'.
  1280     keys add:'open'.
  1236     keys add:'close'.
  1281     keys add:'close'.
  1237     keys add:'yes'.
  1282     keys add:'yes'.
  1238     keys add:'no'.
  1283     keys add:'no'.
  1239 
  1284