'From etoys2.2 of 27 September 2007 [latest update: #1670] on 27 September 2007 at 4:41:11 pm'! "Change Set: fixArrayTransNoop-tak Date: 27 September 2007 Author: Takashi Yamamiya - fix and add a test case for ArrayTransNoop-KR I found ArrayTransNoop ignores symbol as a receiver of #translated. (There are cases in #likelyCategoryToShow) But I don't think it is nessesary, so I ignored it. "! TestCase subclass: #LanguageEditorTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Multilingual-Editor'! !GetTextImporter methodsFor: 'importing' stamp: 'tak 9/27/2007 12:09'! import: aLanguage ^ self import: aLanguage fileNamed: aLanguage localeID posixName , '.po'! ! !LanguageEditorTest methodsFor: 'testing' stamp: 'tak 9/27/2007 16:37'! testFindTranslatedWords "self debug: #testFindTranslatedWords" | message words | message := MethodReference new setStandardClass: self class methodSymbol: #translatedFinderExample. words := TranslatedReceiverFinder new findWordsWith: #findme in: message. self assert: (words includes: 'normal'). self assert: (words includes: 'inside in an array'). self assert: (words includes: 'nested array'). self assert: (words includes: 'nested array again'). self assert: (words includes: 'shouldBeIgnored') not. "Maybe you don't need a symbol" self assert: (words includes: 'symbol') not. "These are Bert's idea of http://lists.laptop.org/pipermail/etoys/2007-September/001189.html" " self assert: (words includes: 'allSymbol'). self assert: (words includes: 'allSymbolAgain'). " ^ words! ! !LanguageEditorTest methodsFor: 'testing' stamp: 'tak 9/27/2007 16:35'! translatedFinderExample 'normal' findme. self flag: #('ignore' 'inside in an array' findme). "This case can be removed" self flag: #(('nested array' shouldBeIgnored 'nested array again')) findme. self flag: #((allSymbol allSymbolAgain)) findme. #symbol findme.! ]style[(23 2 240)f1b,f1,f2! ! !TranslatedReceiverFinder methodsFor: 'accessing' stamp: 'tak 9/27/2007 15:59'! findWordsWith: aSymbol in: aMethodReference "Find words for translation with the symbol in a method. See LanguageEditorTest >>testFindTranslatedWords" "| message | message := MethodReference new setStandardClass: Morph class methodSymbol: #supplementaryPartsDescriptions. self new findWordsWIth: #translatedNoop in: message" | messages keywords aParseNode | aParseNode := aMethodReference decompile. "Find from string literal" messages := Set new. self search: aSymbol messageNode: aParseNode addTo: messages. keywords := OrderedCollection new. messages select: [:aMessageNode | aMessageNode receiver isMemberOf: LiteralNode] thenDo: [:aMessageNode | aMessageNode receiver key literalStringsDo: [:literal | keywords add: literal]]. "Find from array literal" self arraySearch: aSymbol messageNode: aParseNode addTo: keywords. ^ keywords! ! !TranslatedReceiverFinder methodsFor: 'accessing' stamp: 'tak 9/27/2007 15:59'! stringReceiversWithContext: aSymbol "Find string receivers for a symbol. Answer a collection of aMethodReference -> {keyword. keyword...}" "self new stringReceiversWithContext: #translated" | keywords methodReferences | methodReferences _ SystemNavigation default allCallsOn: aSymbol. ^ methodReferences inject: OrderedCollection new into: [:list :next | keywords := self findWordsWith: aSymbol in: next. keywords ifNotEmpty: [list add: next -> keywords]. list] ! !