'From etoys2.2 of 27 September 2007 [latest update: #1689] on 6 October 2007 at 7:16 pm'! "Change Set: underlineCommentGT-tak Date: 6 October 2007 Author: Takashi Yamamiya It replaces all white spaces to _ in gettext comments. Because gettext tools might replace a space to a new line sometimes, and it makes difficult to take a diff."! TestCase subclass: #GettextTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Multilingual-Editor'! !GetTextExporter2 methodsFor: 'file out' stamp: 'tak 10/6/2007 11:29'! exportBody: literals translator: translator "Export a gettext file body. literals is a dictionary of keyword -> #(MethodReference...) in the textDomain." "Build {sortKey. comment. msgid } to optimize sorting (getting category is too slow). If there are two or more methods for a mgsid, only first method (alphabetical) is used for sorting." | sorted msgid sortedMethods category sortKey comment triplets commentUnderLined | triplets := literals associations collect: [:assoc | msgid := assoc key. sortedMethods := assoc value asArray sort. category := (Smalltalk at: sortedMethods first classSymbol) category asString. sortKey := category , ',' , sortedMethods first printString , ',' , msgid. comment := (sortedMethods collect: [:each | each actualClass asString , '>>' , each methodSymbol asString]) inject: category into: [:result :methodName | result , ',' , methodName]. "Replace white spaces to _ because gettext tool might replace a space to a new line some times, and it makes difficult to take a diff." commentUnderLined := comment copyReplaceAll: ' ' with: '_'. Array with: sortKey with: commentUnderLined with: msgid]. "Sort and output the words" sorted := triplets sort: [:a :b | a first <= b first]. sorted do: [:triplet | comment := triplet second. msgid := triplet third. self exportRecordHeader: comment. self exportPhrase: msgid translation: (translator ifNil: [''] ifNotNil: [translator translations at: msgid ifAbsent: ''])]! ! !GettextTest methodsFor: 'testing' stamp: 'tak 10/6/2007 11:31'! testExportBodyWhiteSpace "self debug: #testExportBodyWhiteSpace" | literals exporter | literals := Dictionary new. literals at: 'key1' put: {MethodReference new setStandardClass: Clipboard methodSymbol: #method1}. exporter := GetTextExporter2 new. exporter stream: '' writeStream. exporter exportBody: literals translator: nil. self assert: exporter stream contents = '#: Kernel-ST80_Remnants,Clipboard>>method1 msgid "key1" msgstr "" '! !