[etoys-dev] Etoys: GetText-Richo.3.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon May 24 23:23:24 EDT 2010
Ricardo Moran uploaded a new version of GetText to project Etoys:
http://source.squeak.org/etoys/GetText-Richo.3.mcz
==================== Summary ====================
Name: GetText-Richo.3
Author: Richo
Time: 25 May 2010, 12:23:20 am
UUID: b1f46f99-a999-d64e-8b00-c992d10627f2
Ancestors: GetText-bf.2
* Removed unused classes: GetTextExporter, GetTextInterchange and LanguageEditor.
* Renamed GetTextExporter2 to GetTextExported.
* Fixed #appendStringReceivers:into: to correctly used the default domain when a method doesn't belong to any package.
* Removed all extra information except "Language-Name" and "Language-Direction" (both are only exported to default domain po file).
=============== Diff against GetText-bf.2 ===============
Item was added:
+ ----- Method: GetTextExporter classSide>>exportTemplate (in category 'utilities') -----
+ exportTemplate
+ "GetTextExporter2 exportTemplate"
+ self new exportTemplate.!
Item was added:
+ ----- Method: GetTextExporter>>appendTranslations: (in category 'exporting') -----
+ appendTranslations: domains
+ self appendStringReceivers: #translated into: domains.
+ self appendStringReceivers: #translatedNoop into: domains.
+ self appendVocabularies: domains.
+ !
Item was added:
+ ----- Method: GetTextExporter>>appendStringReceivers:into: (in category 'private') -----
+ appendStringReceivers: aSymbol into: domains
+ | literals references domainName methodReference keywords found |
+
+ found := TranslatedReceiverFinder new stringReceiversWithContext: aSymbol.
+ found do: [ :assoc |
+ methodReference := assoc key.
+ keywords := assoc value.
+ domainName := (PackageOrganizer default packageOfMethod: methodReference ifNone: [nil]).
+ domainName := domainName isNil ifTrue: [TextDomainManager defaultDomain] ifFalse: [domainName name].
+ literals _ domains at: domainName ifAbsentPut: [Dictionary new].
+ keywords do: [ :literal |
+ references _ literals at: literal ifAbsentPut: [OrderedCollection new].
+ references add: methodReference.
+ ].
+ ].
+ !
Item was added:
+ ----- Method: GetTextExporter classSide>>exportAll (in category 'utilities') -----
+ exportAll
+ "GetTextExporter2 exportAll"
+ self new exportTemplate.
+ InternalTranslator availableLanguageLocaleIDs
+ do: [:each | self new exportTranslator: each translator]!
Item was added:
+ ----- Method: GetTextExporter>>exportHeader: (in category 'private') -----
+ exportHeader: domainName
+ | headers |
+ self exportTag: 'msgid' msg: ''.
+ self exportTag: 'msgstr' msg: ''.
+ headers := self createHeaders.
+ headers add: 'X-Etoys-Domain' -> domainName.
+ headers do: [:each | self exportHeaderLineKey: each key value: each value].
+ stream cr; cr!
Item was added:
+ ----- Method: GetTextExporter>>dirNameCategory:translator: (in category 'exporting') -----
+ dirNameCategory: category translator: translator
+ "Answer a file name for the category. Make one if it is not exist yet.
+ Make template file name if translator is nil"
+ "self new dirNameCategory: 'Morphic-Scripting Support' translator:
+ NaturalLanguageTranslator current"
+ "self new dirNameCategory: 'Morphic-Scripting Support' translator: nil"
+ | safeCategory fileName dirName pathName |
+ safeCategory := category copyReplaceAll: ' ' with: '_'.
+ fileName := translator
+ ifNil: [safeCategory , '.pot']
+ ifNotNil: [translator localeID posixName , '.po'].
+ dirName := (safeCategory findTokens: '-')
+ inject: 'po'
+ into: [:aString :next | aString , FileDirectory slash , next].
+ pathName := dirName , FileDirectory slash , fileName.
+ (FileDirectory default directoryNamed: dirName) assureExistence.
+ ^ pathName!
Item was added:
+ ----- Method: GetTextExporter>>stream: (in category 'accessing') -----
+ stream: aStream
+ stream := aStream!
Item was added:
+ ----- Method: GetTextExporter>>appendVocabularies: (in category 'private') -----
+ appendVocabularies: domains
+ | literalsForDomain references domainName methodReference |
+
+ EToyVocabulary allPhrasesWithContextToTranslate do: [ :r |
+ methodReference := (MethodReference new setStandardClass: (r second) methodSymbol: (r third)).
+ "domainName _ self getTextDomainForPackage: (PackageOrganizer default packageOfMethod: methodReference)".
+ domainName := 'Etoys-Tiles'.
+ literalsForDomain _ domains at: domainName ifAbsentPut: [Dictionary new].
+ r fourth do: [ :literal |
+ references _ literalsForDomain at: literal ifAbsentPut: [OrderedCollection new].
+ references add: methodReference.
+ ].
+ ].
+ !
Item was changed:
+ ----- Method: GetTextExporter>>createHeaders (in category 'private') -----
- ----- Method: GetTextExporter>>createHeaders (in category 'private-headers') -----
createHeaders
| headers |
headers := OrderedCollection new.
headers add: 'Project-Id-Version' -> 'eToys'.
headers add: 'POT-Creation-Date' -> self currentDateAndTime.
headers add: 'PO-Revision-Date' -> self currentDateAndTime.
headers add: 'Last-Translator' -> ''.
headers add: 'Language-Team' -> ''.
headers add: 'MIME-Version' -> '1.0'.
headers add: 'Content-Type' -> ('text/plain; charset=', stream converter class encodingNames first).
headers add: 'Content-Transfer-Encoding' -> '8bit'.
+ headers add: 'X-Etoys-SystemVersion' -> (SystemVersion current asString).
^ headers!
Item was added:
+ ----- Method: GetTextExporter>>exportTemplate (in category 'exporting') -----
+ exportTemplate
+ "GetTextExporter2 new exportTemplate"
+ self exportTranslator: nil!
Item was changed:
+ Object subclass: #GetTextExporter
+ instanceVariableNames: 'stream'
- GetTextInterchange subclass: #GetTextExporter
- instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'GetText-Editor'!
+ !GetTextExporter commentStamp: 'Richo 5/24/2010 23:57' prior: 0!
+ Export translations to gettext format divided into categories.
- !GetTextExporter commentStamp: 'tak 7/23/2007 00:31' prior: 0!
- Export translations to one .po file.
+ "Export gettext template files"
+ GetTextExporter new exportTemplate.
+
+ "Export translation files for current locale"
+ GetTextExporter new exportTranslator: (InternalTranslator newLocaleID: LocaleID current).
+
+ "Export all gettext template and po files."
+ GetTextExporter exportAll.
- GetTextExporter new export: NaturalLanguageTranslator current
!
Item was changed:
----- Method: GetTextExporter>>formatReplacements (in category 'private') -----
formatReplacements
| replacements |
replacements := OrderedCollection new.
replacements add: '\' -> '\\'.
replacements add: String cr -> '\n'.
replacements add: String tab -> '\t'.
replacements add: '"' -> '\"'.
^ replacements!
Item was changed:
----- Method: GetTextExporter>>exportTag:singleLine: (in category 'private') -----
exportTag: tag singleLine: aString
stream nextPutAll: tag.
stream space.
stream nextPut: $".
stream
nextPutAll: (self formatString: aString).
stream nextPut: $".
stream cr!
Item was added:
+ ----- Method: GetTextExporter>>stream (in category 'accessing') -----
+ stream
+ ^ stream!
Item was added:
+ ----- Method: GetTextExporter classSide>>listAllHelp (in category 'utilities') -----
+ listAllHelp
+ "self listAllHelp"
+ | spec specs oCatalog flap flapSelectors allKeys oCatalogHelp flapHelp |
+ oCatalog := Dictionary new.
+ Morph withAllSubclasses
+ do: [:aClass | (aClass class includesSelector: #descriptionForPartsBin)
+ ifTrue: [spec := aClass descriptionForPartsBin.
+ oCatalog at: spec formalName put: spec documentation]].
+ Morph withAllSubclasses
+ do: [:aClass | (aClass class includesSelector: #supplementaryPartsDescriptions)
+ ifTrue: [specs := aClass supplementaryPartsDescriptions.
+ specs
+ do: [:each | oCatalog at: each formalName put: each documentation]]].
+ flap := Dictionary new.
+ flapSelectors := #(#defaultsQuadsDefiningPlugInSuppliesFlap #defaultsQuadsDefiningStackToolsFlap #defaultsQuadsDefiningSuppliesFlap #defaultsQuadsDefiningToolsFlap #defaultsQuadsDefiningWidgetsFlap #defaultsQuadsDefiningScriptingFlap ).
+ flapSelectors
+ do: [:selector |
+ specs := Flaps perform: selector.
+ specs
+ do: [:each | flap at: each third put: each fourth]].
+ allKeys := oCatalog keys intersection: flap keys.
+ allKeys asArray sort
+ do: [:each |
+ oCatalogHelp := oCatalog
+ at: each
+ ifAbsent: [''].
+ flapHelp := flap
+ at: each
+ ifAbsent: [''].
+ oCatalogHelp = flapHelp
+ ifFalse: [Transcript cr; show: 'Name: ' , each.
+ Transcript cr; show: 'O: ' , oCatalogHelp.
+ Transcript cr; show: 'F: ' , flapHelp.
+ Transcript cr.
+
+ ]]!
Item was added:
+ ----- Method: GetTextExporter>>exportTranslator: (in category 'exporting') -----
+ exportTranslator: translator
+ "Export translation files. the file extention is 'po', or 'pot' if translator is nil "
+ "GetTextExporter2 new exportTranslator: NaturalLanguageTranslator current "
+ | domains |
+ domains := Dictionary new.
+ self appendTranslations: domains.
+ domains
+ keysAndValuesDo: [:domainName :value |
+ self
+ export: value
+ translator: translator
+ domain: domainName]!
Item was added:
+ ----- Method: GetTextExporter classSide>>coverageStatus (in category 'utilities') -----
+ coverageStatus
+ "self coverageStatus"
+ | keys diff |
+ keys := self keys.
+ diff := InternalTranslator allKnownPhrases keys difference: keys.
+ Transcript cr; show: 'Detected keywords by GetTextExporter2: ' , keys size printString.
+ Transcript cr; show: 'All known phrases in InternalTranslator: ' , InternalTranslator allKnownPhrases size printString.
+ Transcript cr; show: 'Coverage: ' , (keys size / InternalTranslator allKnownPhrases size * 100.0) printString , '%'.
+ diff inspect!
Item was changed:
----- Method: String>>translated (in category '*gettext') -----
translated
"answer the receiver translated to the default language"
+ | translation |
+ translation := self
- ^ self
translatedTo: LocaleID current
+ inDomain: (TextDomainManager domainOfMethod: thisContext sender method).
+ "self = translation ifTrue: [^self translatedInAllDomains]."
+ ^translation!
- inDomain: (TextDomainManager domainOfMethod: thisContext sender method) !
Item was changed:
+ ----- Method: GetTextExporter>>exportPhrase:translation: (in category 'private') -----
- ----- Method: GetTextExporter>>exportPhrase:translation: (in category 'private-translations') -----
exportPhrase: phraseString translation: translationString
+ | normalizedTrans tmp transStartsWithCR transEndsWithCR|
phraseString isEmpty
ifTrue: [^ self].
self exportTag: 'msgid' msg: phraseString.
+ translationString size = 0 ifTrue: [
+ normalizedTrans _ ''
+ ] ifFalse: [
+ transEndsWithCR _ translationString last = (Character cr).
+ phraseString last = (Character cr) ifTrue: [
+ transEndsWithCR ifTrue: [
+ normalizedTrans _ translationString
+ ] ifFalse: [
+ normalizedTrans _ translationString , String cr
+ ]
+ ] ifFalse: [
+ transEndsWithCR ifTrue: [
+ normalizedTrans _ translationString allButLast
+ ] ifFalse: [
+ normalizedTrans _ translationString
+ ]
+ ].
+ transStartsWithCR _ normalizedTrans first = (Character cr).
+ phraseString first = (Character cr) ifTrue: [
+ transStartsWithCR ifFalse: [
+ tmp _ (Character cr asString) , normalizedTrans.
+ normalizedTrans _ tmp.
+ ]
+ ] ifFalse: [
+ transStartsWithCR ifTrue: [
+ normalizedTrans _ normalizedTrans allButFirst
+ ]
+ ]
+ ].
+ self exportTag: 'msgstr' msg: normalizedTrans.
- self exportTag: 'msgstr' msg: translationString.
stream cr!
Item was changed:
+ ----- Method: GetTextExporter>>currentDateAndTime (in category 'private') -----
- ----- Method: GetTextExporter>>currentDateAndTime (in category 'private-headers') -----
currentDateAndTime
^ String
streamContents: [:aStream |
aStream nextPutAll: Date today yyyymmdd;
space.
Time now
print24: true
showSeconds: false
on: aStream.
aStream nextPutAll: '-0000']!
Item was added:
+ ----- Method: GetTextExporter>>createExtraInformation (in category 'private') -----
+ createExtraInformation
+ | extras |
+ extras := OrderedCollection new.
+ #(
+ 'Language name as you''d like it to appear in the Languages menu' 'Language-Name'
+ 'Directionality of language' 'Language-Direction'
+ ) pairsDo: [:first :second |
+ extras add: (Array with: '' with: first with: second).
+ ].
+ ^ extras!
Item was changed:
+ AnObsoleteGetTextInterchange subclass: #GetTextImporter
- GetTextInterchange subclass: #GetTextImporter
instanceVariableNames: 'msgId msgStr state'
classVariableNames: ''
poolDictionaries: ''
category: 'GetText-Editor'!
!GetTextImporter commentStamp: 'tak 10/24/2007 11:23' prior: 0!
GetTextImporter load gettext po file into a InternalTranslator.
GetTextImporter new importID: (LocaleID isoString: 'lang-name') fileNamed: 'lang.po'
!
Item was changed:
----- Method: GetTextExporter>>exportTag:msg: (in category 'private') -----
exportTag: tag msg: aString
| pos end line |
(aString indexOf: Character cr)
= 0
ifTrue: [self exportTag: tag singleLine: aString]
ifFalse: [self exportTag: tag singleLine: ''.
pos := 1.
end := 0.
[end < aString size]
whileTrue: [end := aString indexOf: Character cr startingAt: pos.
end = 0
ifTrue: [end := aString size].
line := aString copyFrom: pos to: end.
stream nextPut: $";
nextPutAll: (self formatString: line);
nextPut: $";
cr.
pos := end + 1]]!
Item was added:
+ ----- Method: GetTextExporter>>dirNameDomain:translator: (in category 'exporting') -----
+ dirNameDomain: domain translator: translator
+ "Answer a file name for the domain. Make one if it is not exist yet.
+ Make template file name if translator is nil"
+ "self new dirNameDomain: 'etoys' translator:
+ NaturalLanguageTranslator current"
+ "self new dirNameDomain: 'etoys' translator: nil"
+ | fileName dirName pathName |
+ "safeCategory := category copyReplaceAll: ' ' with: '_'."
+ fileName := translator
+ ifNil: [domain , '.pot']
+ ifNotNil: [translator localeID posixName , '.po'].
+ dirName := 'po', FileDirectory slash, domain.
+ pathName := dirName , FileDirectory slash , fileName.
+ (FileDirectory default directoryNamed: dirName) assureExistence.
+ ^ pathName!
Item was added:
+ ----- Method: GetTextExporter>>export:translator:domain: (in category 'private') -----
+ export: literals translator: translator domain: domainName
+ | fileName |
+ "Export a gettext file in a category. literals is a dictionary of keyword -> #(MethodReference...) in the textDomain."
+ fileName := self dirNameDomain: domainName translator: translator.
+ [stream := FileStream forceNewFileNamed: fileName.
+ stream lineEndConvention: #lf.
+ stream converter: UTF8TextConverter new.
+ self exportHeader: domainName.
+ domainName = TextDomainManager defaultDomain
+ ifTrue: [self exportInformation: self createExtraInformation].
+ self exportBody: literals translator: translator]
+ ensure: [stream close]!
Item was changed:
+ ----- Method: GetTextExporter>>exportHeaderLineKey:value: (in category 'private') -----
- ----- Method: GetTextExporter>>exportHeaderLineKey:value: (in category 'private-headers') -----
exportHeaderLineKey: keyString value: valueString
stream nextPut: $";
nextPutAll: keyString;
nextPut: $:;
space;
nextPutAll: valueString;
nextPutAll: '\n';
nextPut: $";
+ cr.!
- cr!
Item was added:
+ ----- Method: GetTextExporter>>exportInformation: (in category 'private') -----
+ exportInformation: anOrderedCollection
+ anOrderedCollection do: [:each |
+ self exportRecordHeader: each second.
+ self exportPhrase: each third translation: ''].
+ stream cr.!
Item was added:
+ ----- Method: GetTextExporter>>exportRecordHeader: (in category 'private') -----
+ exportRecordHeader: context
+ stream
+ nextPutAll: '#: ';
+ nextPutAll: context;
+ cr.!
Item was added:
+ ----- Method: GetTextExporter>>exportBody:translator: (in category 'file out') -----
+ 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: (self translationFor: msgid in: translator)]!
Item was added:
+ ----- Method: GetTextExporter>>translationFor:in: (in category 'private') -----
+ translationFor: aKey in: translator
+ translator ifNil: [^''].
+ translator translations at: aKey ifPresent: [:s | ^s].
+ "If we have old camelCase translations, make space-separated words"
+ translator translations at: aKey toCamelCase ifPresent: [:s |
+ (s includes: Character space) ifTrue: [^s].
+ ^s fromCamelCase].
+ ^''!
Item was added:
+ ----- Method: String>>translatedInAllDomains (in category '*gettext') -----
+ translatedInAllDomains
+ | translation |
+ Transcript show: self printString, ' translatedInAllDomains'; cr.
+ TextDomainManager allKnownDomains do: [:domain |
+ translation := self translatedInDomain: domain.
+ self = translation ifFalse: [^translation]
+ ].
+ ^self!
Item was changed:
----- Method: GetTextExporter>>formatString: (in category 'private') -----
formatString: aString
| result |
result := aString.
self formatReplacements
do: [:each | result := result copyReplaceAll: each key with: each value].
^ result!
Item was added:
+ ----- Method: GetTextExporter classSide>>keys (in category 'utilities') -----
+ keys
+ | categories |
+ categories := Dictionary new.
+ self new appendTranslations: categories.
+ ^ categories values
+ inject: Set new
+ into: [:set :next | set addAll: next keys;
+ yourself]!
Item was added:
+ ----- Method: GetTextExporter classSide>>verifyExport (in category 'utilities') -----
+ verifyExport
+ "Same as #verifyMsgID: but it writes / reads .po files actually"
+ "self verifyExport"
+ "InternalTranslator removeLocaleID: (LocaleID isoString: 'test-US')"
+ | src dst localeID |
+ localeID := LocaleID isoString: 'test-US'.
+ self verifyMsgID: localeID.
+ src := localeID translator.
+ self new exportTranslator: src.
+ InternalTranslator removeLocaleID: localeID.
+ dst := localeID translator.
+ GetTextImporter import: dst allDirectory: FileDirectory default!
Item was added:
+ ----- Method: GetTextExporter classSide>>verifyMsgID: (in category 'utilities') -----
+ verifyMsgID: localeID
+ "GetTextExporter2 verifyMsgID: (LocaleID isoString: 'test-US')"
+ "InternalTranslator removeLocaleID: (LocaleID isoString: 'test-US')"
+ "Test gettext keyword extract function without file I/O.
+ A language named <langName> will be made. And
+ all possible translated words are shown with extra X charactor like
+ 'XwordX' in the language."
+ | src |
+ InternalTranslator removeLocaleID: localeID.
+ src := localeID translator.
+ self keys
+ do: [:key | src generics at: key put: 'X' , key , 'X']!
Item was removed:
- ----- Method: GetTextInterchange>>defaultFileName (in category 'private') -----
- defaultFileName
- ^ language localeID posixName , '.po'!
Item was removed:
- ----- Method: MOFile>>loadString:pointer:length: (in category 'private') -----
- loadString: strm pointer: top length: len
- | str |
- str _ ByteString new: len.
- strm position: top.
- strm nextInto: str.
- ^str replaceAll: Lf with: Cr.
- !
Item was removed:
- ----- Method: LanguageEditor>>translationsFilterWording (in category 'gui methods') -----
- translationsFilterWording
- ^ (self translationsFilter isEmpty
- ifTrue: ['filter' translated]
- ifFalse: ['filtering: {1}' translated format:{self translationsFilter}]) !
Item was removed:
- ----- Method: MOFile>>testSearchByDictionary (in category 'experimental') -----
- testSearchByDictionary
- InternalTranslator allKnownPhrases
- do: [:each |
- self searchByDictionary: each
- ].
- !
Item was removed:
- ----- Method: LanguageEditor>>numberOfTimesStringIsUsed: (in category 'stef') -----
- numberOfTimesStringIsUsed: aString
-
- ^ (self systemNavigation allSelect: [:method | method
- hasLiteralSuchThat: [:lit | lit isString
- and: [lit includesSubstring: aString caseSensitive: true]]]) size!
Item was removed:
- ----- Method: LanguageEditor>>delete (in category 'open/close') -----
- delete
- "Remove the receiver as a submorph of its owner"
- self model: nil.
- super delete !
Item was removed:
- ----- Method: LanguageEditor>>untranslatedFilter (in category 'accessing') -----
- untranslatedFilter
- ^ untranslatedFilter
- ifNil: ['']!
Item was removed:
- ----- Method: String>>translatedInAnyDomain (in category '*gettext') -----
- translatedInAnyDomain
- | translation |
- Transcript show: self printString, ' translatedInAnyDomain'; cr.
- TextDomainManager allKnownDomains do: [:domain |
- translation := self translatedInDomain: domain.
- self = translation ifFalse: [^translation]
- ].
- ^self!
Item was removed:
- ----- Method: GetTextExporter>>exportTranslations (in category 'private-translations') -----
- exportTranslations
- | keys size |
- keys := language translations keys asArray sort.
- size := keys size.
- ProgressInitiationException
- display: 'Exporting translated phrases as a gettext file.'
- during: [:bar | 1
- to: size
- do: [:index |
- self
- exportPhrase: (keys at: index)
- translation: (language translations
- at: (keys at: index)).
- bar value: index / size]]!
Item was removed:
- ----- Method: LanguageEditor class>>unload (in category 'initialize-release') -----
- unload
- "the receiver is being unloaded"
- (TheWorldMenu respondsTo: #registerOpenCommand:)
- ifTrue: [""
- TheWorldMenu unregisterOpenCommand: 'Language Editor'.
- TheWorldMenu unregisterOpenCommand: 'Language Editor for...'] !
Item was removed:
- ----- Method: LanguageEditor>>translator (in category 'private') -----
- translator
- ^translator!
Item was removed:
- ----- Method: LanguageEditor>>initializeToolbars (in category 'initialization - toolbar') -----
- initializeToolbars
- "initialize the receiver's toolbar"
- self
- addMorph: self createMainToolbar
- frame: (0 @ 0 corner: 1 @ 0.09).
- ""
- self
- addMorph: self createTranslationsToolbar
- frame: (0 @ 0.09 corner: 0.5 @ 0.18).
- self
- addMorph: self createUntranslatedToolbar
- frame: (0.5 @ 0.09 corner: 1 @ 0.18)!
Item was removed:
- ----- Method: LanguageEditor>>reportString (in category 'reporting') -----
- reportString
- "answer a string with a report of the receiver"
- | stream |
- stream := String new writeStream.
- self printReportOn: stream.
- ^ stream contents!
Item was removed:
- Object subclass: #TextDomainManager
- instanceVariableNames: ''
- classVariableNames: 'ClassCategories Classes DefaultDomain DomainInfos LoneClasses Packages'
- poolDictionaries: ''
- category: 'GetText-Localization'!
- TextDomainManager class
- instanceVariableNames: 'defaultDomain'!
-
- !TextDomainManager commentStamp: 'tk 1/4/2008 16:08' prior: 0!
- I manages mapping from class category to textdomain.
-
- Class variables:
- ClassCategories IdentityDictionary -- classCategory -> domainName
- Classes IdentityDictionary -- class name (a Symbol) -> domainName (a cache only!!)
- DefaultDomain String -- the default domain name
- DomainInfos Dictionary -- domainName -> a TextDomainInfo
- LoneClasses IdentityDictionary -- class name (a Symbol) -> domainName. For classes whose entire category are not all in the same domain (BookMorph and QuickGuideMorph)
-
- TextDomainManager registerCategoryPrefix: 'DrGeoII' domain: 'DrGeoII'.
- TextDomainManager unregisterDomain: 'DrGeoII'.
-
- TextDomainManager registerClass: #QuickGuideMorph domain: 'quickguides'.
- TextDomainManager registerClass: #QuickGuideHolderMorph domain: 'quickguides'.
- !
- TextDomainManager class
- instanceVariableNames: 'defaultDomain'!
Item was removed:
- ----- Method: MOFile>>nextInt32From: (in category 'private') -----
- nextInt32From: strm
- ^isLittleEndian
- ifTrue: [^strm nextLittleEndianNumber: 4]
- ifFalse: [^strm nextInt32]!
Item was removed:
- ----- Method: LanguageEditor>>refreshBoth (in category 'updating') -----
- refreshBoth
- self refreshUntranslated
- !
Item was removed:
- ----- Method: LanguageEditor>>addTranslation (in category 'gui methods') -----
- addTranslation
- "translate a phrase"
- | phrase |
- phrase := FillInTheBlank
- request: 'enter the original:' translated
- initialAnswer: ''.
-
- (phrase isNil
- or: [phrase = ''])
- ifTrue: [""
- self beep.
- ^ self].
- ""
- self translatePhrase: phrase!
Item was removed:
- ----- Method: LanguageEditor>>refreshUntranslated (in category 'updating') -----
- refreshUntranslated
- "refresh the untranslated panel"
- self refreshTranslations.
- self selectedUntranslated: 0.
- untranslated := nil.
- self changed: #untranslated.
- !
Item was removed:
- ----- Method: TextDomainManager classSide>>allKnownDomains (in category 'accessing') -----
- allKnownDomains
- "Every package has it's own text domain now so it's not necessary to keep a registry of all domains, we can simply return all the packages in the image.
- PROBLEM: If a package doesn't contain translations, it won't have a mo file but the GetTextTranslator will try to load it anyway. This happens when we switch languages. So far I tested it briefly and it seems to work..."
- ^PackageOrganizer default packageNames!
Item was removed:
- ----- Method: LanguageEditor>>checkUntranslatedPhrase: (in category 'private') -----
- checkUntranslatedPhrase: phraseString
- "check the phrase an aswer a string with a comment or a nil
- meaning no-comments"
-
- (self translations includes: phraseString)
- ifTrue: [^ 'possible double-translation' translated].
-
- ^ nil!
Item was removed:
- ----- Method: LanguageEditor class>>open (in category 'opening') -----
- open
- "open the receiver on any language"
- "
- LanguageEditor open.
- "
- | menu |
- menu := MenuMorph new defaultTarget: self.
- menu addTitle: 'Language Editor for...' translated.
- ""
- (InternalTranslator availableLanguageLocaleIDs
- asSortedCollection: [:x :y | x asString <= y asString])
- do: [:eachLanguage | ""
- menu
- add: eachLanguage name
- target: self
- selector: #openOn:
- argument: eachLanguage].
- ""
- menu popUpInWorld!
Item was removed:
- ----- Method: GetTextExporter2>>translationFor:in: (in category 'private') -----
- translationFor: aKey in: translator
- translator ifNil: [^''].
- translator translations at: aKey ifPresent: [:s | ^s].
- "If we have old camelCase translations, make space-separated words"
- translator translations at: aKey toCamelCase ifPresent: [:s |
- (s includes: Character space) ifTrue: [^s].
- ^s fromCamelCase].
- ^''!
Item was removed:
- ----- Method: LanguageEditor>>translationsKeystroke: (in category 'gui methods') -----
- translationsKeystroke: aChar
- "Respond to a Command key in the translations list."
- aChar == $x
- ifTrue: [^ self removeTranslation].
- aChar == $E
- ifTrue: [^ self browseMethodsWithTranslation]!
Item was removed:
- ----- Method: MOFile>>loadStrings:pointers:encoding:languageEnvironment: (in category 'private') -----
- loadStrings: strm pointers: tupple encoding: encodingName languageEnvironment: env
- | strings rawStr str offsetTable lenTable |
- offsetTable _ tupple first.
- lenTable _ tupple second.
- strings _ Array new: nStrings.
- 1 to: nStrings do: [:index |
- rawStr _ self loadString: strm
- pointer: (offsetTable at: index)
- length: (lenTable at: index).
- str _ encodingName isNil ifTrue: [rawStr]
- ifFalse: [ encodingName = 'utf8'
- ifTrue: [rawStr utf8ToSqueak applyLanguageInfomation: env]
- ifFalse: [self error: 'this encoding isn''t supported']
- ].
- strings at: index put: str.
- ].
- ^strings.!
Item was removed:
- ----- Method: GetTextExporter2>>exportTranslator: (in category 'exporting') -----
- exportTranslator: translator
- "Export translation files. the file extention is 'po', or 'pot' if translator is nil "
- "GetTextExporter2 new exportTranslator: NaturalLanguageTranslator current "
- | domains |
- domains := Dictionary new.
- self appendTranslations: domains.
- domains
- keysAndValuesDo: [:domainName :value |
- self
- export: value
- translator: translator
- domain: domainName]!
Item was removed:
- ----- Method: MOFile>>atRandom (in category 'public') -----
- atRandom
-
- ^ self translatedString:nStrings atRandom.
- !
Item was removed:
- ----- Method: MOFile classSide>>fileName:localeID: (in category 'instance creation') -----
- fileName: path localeID: id
- ^self new
- load:path localeID: id!
Item was removed:
- ----- Method: GetTextExporter2>>appendTranslations: (in category 'exporting') -----
- appendTranslations: domains
- self appendStringReceivers: #translated into: domains.
- self appendStringReceivers: #translatedNoop into: domains.
- self appendVocabularies: domains.
- !
Item was removed:
- ----- Method: LanguageEditor>>identifyUnusedStrings (in category 'stef') -----
- identifyUnusedStrings
- "self new identifyUnusedStrings"
- translationsList getList
- do: [:each |
- Transcript show: each.
- Transcript show: (Smalltalk
- allSelect: [:method | method
- hasLiteralSuchThat: [:lit | lit isString
- and: [lit includesSubstring: each caseSensitive: true]]]) size printString; cr]!
Item was removed:
- ----- Method: LanguageEditor>>initializePanels (in category 'initialization') -----
- initializePanels
- "initialize the receiver's panels"
- translationsList := PluggableListMorphOfMany
- on: self
- list: #translations
- primarySelection: #selectedTranslation
- changePrimarySelection: #selectedTranslation:
- listSelection: #selectedTranslationsAt:
- changeListSelection: #selectedTranslationsAt:put:
- menu: #translationsMenu:
- keystroke: #translationsKeystroke:.
- translationsList setBalloonText: 'List of all the translated phrases.' translated.
- ""
- untranslatedList := PluggableListMorph
- on: self
- list: #untranslated
- selected: #selectedUntranslated
- changeSelected: #selectedUntranslated:
- menu: #untranslatedMenu:
- keystroke: #untranslatedKeystroke:.
- untranslatedList setBalloonText: 'List of all the untranslated phrases.' translated.
- ""
- translationText := PluggableTextMorph
- on: self
- text: #translation
- accept: #translation:
- readSelection: nil
- menu: nil.
- translationText setBalloonText: 'Translation for the selected phrase in the upper list.' translated.
- ""
- self
- addMorph: translationsList
- frame: (0 @ 0.18 corner: 0.5 @ 0.66).
- self
- addMorph: untranslatedList
- frame: (0.5 @ 0.18 corner: 1 @ 0.93).
- self
- addMorph: translationText
- frame: (0 @ 0.66 corner: 0.5 @ 0.93).
- self hResizing: #shrinkWrap!
Item was removed:
- ----- Method: LanguageEditor class>>openOnDefault (in category 'opening') -----
- openOnDefault
- "open the receiver on the default language"
- self openOn: LocaleID current!
Item was removed:
- ----- Method: MOFile>>fileName (in category 'public') -----
- fileName
- ^fileName!
Item was removed:
- ----- Method: LanguageEditor>>translation: (in category 'accessing') -----
- translation: aStringOrText
- "change the translation for the selected phrase"
- | phrase |
- self selectedTranslation isZero
- ifTrue: [^ self].
- phrase _ self translations at: self selectedTranslation.
- translator
- phrase: phrase
- translation: aStringOrText asString.
- newerKeys add: phrase.
- ^ true!
Item was removed:
- ----- Method: GetTextInterchange>>stream (in category 'accessing') -----
- stream
- ^ stream!
Item was removed:
- ----- Method: LanguageEditor>>applyTranslations (in category 'gui methods') -----
- applyTranslations
- "private - try to apply the translations as much as possible all
- over the image"
- Project current updateLocaleDependents!
Item was removed:
- ----- Method: MOFile>>translationFor: (in category 'public') -----
- translationFor: aString
- | file |
- aString size = 0 ifTrue: [^ '']. "Gettext header"
- ^ (self searchByDictionary: aString) ifNil: [
- file := (fileName subStrings: '\').
- Transcript show: aString printString, ' not found in ', "(file atLast: 3),'\', "(file last); cr.^aString]
- !
Item was removed:
- ----- Method: GetTextExporter2>>stream: (in category 'accessing') -----
- stream: aStream
- stream := aStream!
Item was removed:
- ----- Method: GetTextExporter2 classSide>>coverageStatus (in category 'utilities') -----
- coverageStatus
- "self coverageStatus"
- | keys diff |
- keys := self keys.
- diff := InternalTranslator allKnownPhrases keys difference: keys.
- Transcript cr; show: 'Detected keywords by GetTextExporter2: ' , keys size printString.
- Transcript cr; show: 'All known phrases in InternalTranslator: ' , InternalTranslator allKnownPhrases size printString.
- Transcript cr; show: 'Coverage: ' , (keys size / InternalTranslator allKnownPhrases size * 100.0) printString , '%'.
- diff inspect!
Item was removed:
- ----- Method: GetTextExporter2 classSide>>verifyMsgID: (in category 'utilities') -----
- verifyMsgID: localeID
- "GetTextExporter2 verifyMsgID: (LocaleID isoString: 'test-US')"
- "InternalTranslator removeLocaleID: (LocaleID isoString: 'test-US')"
- "Test gettext keyword extract function without file I/O.
- A language named <langName> will be made. And
- all possible translated words are shown with extra X charactor like
- 'XwordX' in the language."
- | src |
- InternalTranslator removeLocaleID: localeID.
- src := localeID translator.
- self keys
- do: [:key | src generics at: key put: 'X' , key , 'X']!
Item was removed:
- ----- Method: LanguageEditor>>selectedTranslationsAt: (in category 'accessing') -----
- selectedTranslationsAt: index
- ^ selectedTranslations includes: index!
Item was removed:
- ----- Method: LanguageEditor>>getTextImport (in category 'gui methods') -----
- getTextImport
- | menu |
- menu := MenuMorph new defaultTarget: self.
- menu addTitle: 'Choose translation file' translated.
- menu add: 'All *.po files' translated action: #getTextImportAll.
- menu add: 'Choose a file' translated action: #getTextImportAFile.
- menu popUpInWorld!
Item was removed:
- ----- Method: GetTextExporter2>>exportHeaderLineKey:value: (in category 'private') -----
- exportHeaderLineKey: keyString value: valueString
- stream nextPut: $";
- nextPutAll: keyString;
- nextPut: $:;
- space;
- nextPutAll: valueString;
- nextPutAll: '\n';
- nextPut: $";
- cr.!
Item was removed:
- ----- Method: LanguageEditor>>translations (in category 'accessing') -----
- translations
- "answet the translator's translations"
- | allTranslations filterString |
- translations ifNotNil: [^translations].
- allTranslations := self translator translations keys.
- ""
- filterString := self translationsFilter.
- ""
- filterString isEmpty
- ifFalse: [allTranslations := allTranslations
- select: [:each | ""
- ('*' , filterString , '*' match: each)
- or: ['*' , filterString , '*'
- match: (self translator translate: each)]]].
- ""
- ^ translations _ allTranslations asSortedCollection asArray!
Item was removed:
- ----- Method: LanguageEditor>>searchUntranslated (in category 'gui methods') -----
- searchUntranslated
- | search |
- search := FillInTheBlank request: 'search for' translated initialAnswer: ''.
- (search isNil
- or: [search isEmpty])
- ifTrue: [""
- self beep.
- ^ self].
- ""
- self searchUntranslated: search!
Item was removed:
- ----- Method: GetTextExporter2>>dirNameDomain:translator: (in category 'exporting') -----
- dirNameDomain: domain translator: translator
- "Answer a file name for the domain. Make one if it is not exist yet.
- Make template file name if translator is nil"
- "self new dirNameDomain: 'etoys' translator:
- NaturalLanguageTranslator current"
- "self new dirNameDomain: 'etoys' translator: nil"
- | fileName dirName pathName |
- "safeCategory := category copyReplaceAll: ' ' with: '_'."
- fileName := translator
- ifNil: [domain , '.pot']
- ifNotNil: [translator localeID posixName , '.po'].
- dirName := 'po', FileDirectory slash, domain.
- pathName := dirName , FileDirectory slash , fileName.
- (FileDirectory default directoryNamed: dirName) assureExistence.
- ^ pathName!
Item was removed:
- ----- Method: GetTextExporter2>>createHeaders (in category 'private') -----
- createHeaders
- | headers |
- headers := OrderedCollection new.
- headers add: 'Project-Id-Version' -> 'eToys'.
- headers add: 'POT-Creation-Date' -> self currentDateAndTime.
- headers add: 'PO-Revision-Date' -> self currentDateAndTime.
- headers add: 'Last-Translator' -> ''.
- headers add: 'Language-Team' -> ''.
- headers add: 'MIME-Version' -> '1.0'.
- headers add: 'Content-Type' -> ('text/plain; charset=', stream converter class encodingNames first).
- headers add: 'Content-Transfer-Encoding' -> '8bit'.
- headers add: 'X-Etoys-SystemVersion' -> (SystemVersion current asString).
- ^ headers!
Item was removed:
- ----- Method: LanguageEditor>>codeSelectedTranslationAsMimeString (in category 'gui methods') -----
- codeSelectedTranslationAsMimeString
- | keys code tmpStream s2 gzs cont |
- keys := selectedTranslations
- collect: [:key | self translations at: key].
- code := String
- streamContents: [:aStream | self translator fileOutOn: aStream keys: keys withBOM: false].
-
- tmpStream _ MultiByteBinaryOrTextStream on: ''.
- tmpStream converter: UTF8TextConverter new.
- tmpStream nextPutAll: code.
- s2 _ RWBinaryOrTextStream on: ''.
- gzs := GZipWriteStream on: s2.
- tmpStream reset.
- gzs nextPutAll: (tmpStream binary contentsOfEntireFile asString) contents.
- gzs close.
- s2 reset.
-
- cont _ String streamContents: [:strm |
- strm nextPutAll: '"Gzip+Base64 encoded translation for;'; cr.
- strm nextPutAll: '#('.
- keys do: [:each | strm nextPutAll: '''', each, ''' '.].
- strm nextPutAll: ')"'; cr; cr.
- strm nextPutAll: 'NaturalLanguageTranslator loadForLocaleIsoString: '.
- strm nextPut: $'.
- strm nextPutAll: translator localeID isoString.
- strm nextPut: $'.
- strm nextPutAll: ' fromGzippedMimeLiteral: '.
- strm nextPut: $'.
- strm nextPutAll: (Base64MimeConverter mimeEncode: s2) contents.
- strm nextPutAll: '''.'.
- strm cr.
- ].
-
- (StringHolder new contents: cont)
- openLabel: 'exported codes in Gzip+Base64 encoding' translated!
Item was removed:
- ----- Method: LanguageEditor>>selectTranslationPhrase: (in category 'gui methods') -----
- selectTranslationPhrase: phraseString
- self selectedTranslation: (self translations indexOf: phraseString)!
Item was removed:
- ----- Method: GetTextExporter2 classSide>>verifyExport (in category 'utilities') -----
- verifyExport
- "Same as #verifyMsgID: but it writes / reads .po files actually"
- "GetTextExporter2 verifyExport"
- "InternalTranslator removeLocaleID: (LocaleID isoString: 'test-US')"
- | src dst localeID |
- localeID := LocaleID isoString: 'test-US'.
- self verifyMsgID: localeID.
- src := localeID translator.
- GetTextExporter2 new exportTranslator: src.
- InternalTranslator removeLocaleID: localeID.
- dst := localeID translator.
- GetTextImporter import: dst allDirectory: FileDirectory default!
Item was removed:
- ----- Method: TextDomainManager classSide>>allMethodsWithTranslations (in category 'accessing') -----
- allMethodsWithTranslations
- "Look for #translated calls"
- | methodsWithTranslations |
- methodsWithTranslations := TranslatedReceiverFinder new stringReceiversWithContext: #translated.
- methodsWithTranslations := methodsWithTranslations, (TranslatedReceiverFinder new
- stringReceiversWithContext: #translatedNoop).
-
- methodsWithTranslations := methodsWithTranslations collect: [:each | each key compiledMethod].
-
- "Look for Etoys tiles and vocabularies"
- methodsWithTranslations := methodsWithTranslations, (EToyVocabulary allPhrasesWithContextToTranslate collect: [:r |
- (MethodReference new setStandardClass: r second methodSymbol: r third) compiledMethod.
- ]).
-
- ^methodsWithTranslations!
Item was removed:
- ----- Method: LanguageEditor>>printReportOn: (in category 'reporting') -----
- printReportOn: aStream
- "append to aStream a report of the receiver with swiki format"
- self printHeaderReportOn: aStream.
- self printUntranslatedReportOn: aStream.
- self printTranslationsReportOn: aStream!
Item was removed:
- ----- Method: GetTextExporter2 classSide>>listAllHelp (in category 'utilities') -----
- listAllHelp
- "self listAllHelp"
- | spec specs oCatalog flap flapSelectors allKeys oCatalogHelp flapHelp |
- oCatalog := Dictionary new.
- Morph withAllSubclasses
- do: [:aClass | (aClass class includesSelector: #descriptionForPartsBin)
- ifTrue: [spec := aClass descriptionForPartsBin.
- oCatalog at: spec formalName put: spec documentation]].
- Morph withAllSubclasses
- do: [:aClass | (aClass class includesSelector: #supplementaryPartsDescriptions)
- ifTrue: [specs := aClass supplementaryPartsDescriptions.
- specs
- do: [:each | oCatalog at: each formalName put: each documentation]]].
- flap := Dictionary new.
- flapSelectors := #(#defaultsQuadsDefiningPlugInSuppliesFlap #defaultsQuadsDefiningStackToolsFlap #defaultsQuadsDefiningSuppliesFlap #defaultsQuadsDefiningToolsFlap #defaultsQuadsDefiningWidgetsFlap #defaultsQuadsDefiningScriptingFlap ).
- flapSelectors
- do: [:selector |
- specs := Flaps perform: selector.
- specs
- do: [:each | flap at: each third put: each fourth]].
- allKeys := oCatalog keys intersection: flap keys.
- allKeys asArray sort
- do: [:each |
- oCatalogHelp := oCatalog
- at: each
- ifAbsent: [''].
- flapHelp := flap
- at: each
- ifAbsent: [''].
- oCatalogHelp = flapHelp
- ifFalse: [Transcript cr; show: 'Name: ' , each.
- Transcript cr; show: 'O: ' , oCatalogHelp.
- Transcript cr; show: 'F: ' , flapHelp.
- Transcript cr.
-
- ]]!
Item was removed:
- ----- Method: LanguageEditor class>>initialize (in category 'initialize-release') -----
- initialize
- "initialize the receiver"
- (TheWorldMenu respondsTo: #registerOpenCommand:)
- ifTrue: [""
- TheWorldMenu registerOpenCommand: {'Language Editor' translated. {self. #openOnDefault}}.
- TheWorldMenu registerOpenCommand: {'Language Editor for...' translated. {self. #open}}]!
Item was removed:
- ----- Method: GetTextExporter2>>exportInformation: (in category 'private') -----
- exportInformation: anOrderedCollection
- anOrderedCollection do: [:each |
- self exportRecordHeader: each second.
- self exportPhrase: each third translation: ''].
- stream cr.!
Item was removed:
- ----- Method: LanguageEditor>>createMainToolbar (in category 'initialization - toolbar') -----
- createMainToolbar
- "create a toolbar for the receiver"
- | toolbar |
- toolbar := self createRow.
- ""
- " toolbar
- addMorphBack: (self
- createUpdatingButtonWording: #debugWording
- action: #switchDebug
- help: 'Switch the debug flag')."
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- ""
- toolbar
- addMorphBack: (self
- createButtonLabel: 'new'
- action: #newTranslations
- help: 'Create translations for new language.').
- toolbar
- addMorphBack: (self
- createButtonLabel: 'save'
- action: #saveToFile
- help: 'Save the translations to a file').
- toolbar
- addMorphBack: (self
- createButtonLabel: 'load'
- action: #loadFromFile
- help: 'Load the translations from a file').
- toolbar
- addMorphBack: (self
- createButtonLabel: 'merge'
- action: #mergeFromFile
- help: 'Merge the current translations with the translations in a file').
- ""
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- toolbar
- addMorphBack: (self
- createButtonLabel: 'apply'
- action: #applyTranslations
- help: 'Apply the translations as much as possible.').
- ""
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- toolbar
- addMorphBack: (self
- createButtonLabel: 'check translations'
- action: #check
- help: 'Check the translations and report the results.').
- toolbar
- addMorphBack: (self
- createButtonLabel: 'report'
- action: #report
- help: 'Create a report.').
- toolbar
- addMorphBack: (self
- createButtonLabel: 'gettext'
- action: #getText
- help: 'Interface with gettext.').
- ""
- ^ toolbar!
Item was removed:
- ----- Method: LanguageEditor>>mergeFromFile (in category 'gui methods') -----
- mergeFromFile
- | fileName |
- fileName := self selectTranslationFileName.
- fileName isNil
- ifTrue: [""
- self beep.
- ^ self].
- ""
- Cursor wait
- showWhile: [
- self translator loadFromFileNamed: fileName.
- self refreshBoth]!
Item was removed:
- ----- Method: LanguageEditor>>translation (in category 'accessing') -----
- translation
- "answer the translation for the selected phrase"
- self selectedTranslation isZero
- ifTrue: [^ '<select a phrase from the upper list>' translated].
- ""
- ^ self translator
- translate: (self translations at: self selectedTranslation)!
Item was removed:
- ----- Method: LanguageEditor>>getTextExport (in category 'gui methods') -----
- getTextExport
- Cursor wait
- showWhile: [GetTextExporter2 new exportTranslator: self model]!
Item was removed:
- ----- Method: LanguageEditor>>filterTranslations (in category 'gui methods') -----
- filterTranslations
- | filter |
- filter := FillInTheBlank request: 'filter with
- (empty string means no-filtering)' translated initialAnswer: self translationsFilter.
- ""
- self filterTranslations: filter!
Item was removed:
- ----- Method: GetTextExporter2>>exportRecordHeader: (in category 'private') -----
- exportRecordHeader: context
- stream
- nextPutAll: '#: ';
- nextPutAll: context;
- cr.!
Item was removed:
- ----- Method: LanguageEditor>>browseMethodsWithUntranslated (in category 'gui methods') -----
- browseMethodsWithUntranslated
- | untrans |
- self selectedUntranslated isZero
- ifTrue: [""
- self beep.
- self inform: 'select the untrans phrase to look for' translated.
- ^ self].
- ""
- untrans := self untranslated at: self selectedUntranslated.
- SystemNavigation default browseMethodsWithLiteral: untrans.
- !
Item was removed:
- ----- Method: LanguageEditor>>selectedUntranslated (in category 'accessing') -----
- selectedUntranslated
- "answer the selectedUntranslated"
- ^ selectedUntranslated!
Item was removed:
- ----- Method: LanguageEditor>>untranslatedKeystroke: (in category 'gui methods') -----
- untranslatedKeystroke: aChar
- "Respond to a Command key in the translations list."
- aChar == $t
- ifTrue: [^ self translate].
- aChar == $E
- ifTrue: [^ self browseMethodsWithUntranslated]!
Item was removed:
- ----- Method: LanguageEditor>>filterTranslations: (in category 'gui methods') -----
- filterTranslations: aString
- | filter |
- filter := aString ifNil:[''].
- ""
- translationsFilter _ filter.
- self refreshTranslations.
- !
Item was removed:
- ----- Method: LanguageEditor>>searchUntranslated: (in category 'gui methods') -----
- searchUntranslated: aString
- | untranslateds results index |
- untranslateds := self untranslated.
- results := untranslateds
- select: [:each | '*' , aString , '*' match: each].
- ""
- results isEmpty
- ifTrue: [""
- self inform: 'no matches for' translated , ' ''' , aString , ''''.
- ^ self].
- ""
- results size = 1
- ifTrue: [""
- self selectUntranslatedPhrase: results first.
- ^ self].
- ""
- index := (PopUpMenu
- labelArray: (results
- collect: [:each | each copy replaceAll: Character cr with: $\]))
- startUpWithCaption: 'select the untranslated phrase...' translated.
- ""
- index isZero
- ifTrue: [""
- self beep.
- ^ self].
- ""
- self
- selectUntranslatedPhrase: (results at: index)!
Item was removed:
- ----- Method: LanguageEditor>>deselectAllTranslation (in category 'gui methods') -----
- deselectAllTranslation
- selectedTranslations := IdentitySet new.
- self changed: #allSelections!
Item was removed:
- ----- Method: LanguageEditor>>check (in category 'private') -----
- check
- "check the translations and answer a collection with the results"
- | results counter phrasesCount checkMethod |
- results := OrderedCollection new.
- untranslated := self untranslated.
- phrasesCount := self translations size + self untranslated size.
- counter := 0.
- checkMethod := self class checkMethods at: self translator localeID printString ifAbsent: [^results].
-
- self translations
- keysAndValuesDo: [:phrase :translation |
- | result |
- result := self perform: checkMethod with: phrase with: translation.
- (result notNil
- and: [result notEmpty])
- ifTrue: [results add: {phrase. translation. result}].
-
- counter := counter + 1.
- (counter isDivisibleBy: 50)
- ifTrue: [| percent |
- percent := counter / phrasesCount * 100 roundTo: 0.01.
- Transcript
- show: ('- checked {1} phrases of {2} ({3}%)...' translated format: {counter. phrasesCount. percent});
- cr]].
-
- self untranslated
- do: [:phrase |
- | result |
- result := self checkUntranslatedPhrase: phrase.
- (result notNil
- and: [result notEmpty])
- ifTrue: [results add: {phrase. nil. result}].
-
- counter := counter + 1.
- (counter isDivisibleBy: 50)
- ifTrue: [| percent |
- percent := counter / phrasesCount * 100 roundTo: 0.01.
- Transcript
- show: ('- checked {1} phrases of {2} ({3}%)...' translated format: {counter. phrasesCount. percent});
- cr]].
-
- ^ results!
Item was removed:
- ----- Method: GetTextExporter2>>dirNameCategory:translator: (in category 'exporting') -----
- dirNameCategory: category translator: translator
- "Answer a file name for the category. Make one if it is not exist yet.
- Make template file name if translator is nil"
- "self new dirNameCategory: 'Morphic-Scripting Support' translator:
- NaturalLanguageTranslator current"
- "self new dirNameCategory: 'Morphic-Scripting Support' translator: nil"
- | safeCategory fileName dirName pathName |
- safeCategory := category copyReplaceAll: ' ' with: '_'.
- fileName := translator
- ifNil: [safeCategory , '.pot']
- ifNotNil: [translator localeID posixName , '.po'].
- dirName := (safeCategory findTokens: '-')
- inject: 'po'
- into: [:aString :next | aString , FileDirectory slash , next].
- pathName := dirName , FileDirectory slash , fileName.
- (FileDirectory default directoryNamed: dirName) assureExistence.
- ^ pathName!
Item was removed:
- ----- Method: GetTextExporter2>>exportPhrase:translation: (in category 'private') -----
- exportPhrase: phraseString translation: translationString
- | normalizedTrans tmp transStartsWithCR transEndsWithCR|
- phraseString isEmpty
- ifTrue: [^ self].
- self exportTag: 'msgid' msg: phraseString.
- translationString size = 0 ifTrue: [
- normalizedTrans _ ''
- ] ifFalse: [
- transEndsWithCR _ translationString last = (Character cr).
- phraseString last = (Character cr) ifTrue: [
- transEndsWithCR ifTrue: [
- normalizedTrans _ translationString
- ] ifFalse: [
- normalizedTrans _ translationString , String cr
- ]
- ] ifFalse: [
- transEndsWithCR ifTrue: [
- normalizedTrans _ translationString allButLast
- ] ifFalse: [
- normalizedTrans _ translationString
- ]
- ].
- transStartsWithCR _ normalizedTrans first = (Character cr).
- phraseString first = (Character cr) ifTrue: [
- transStartsWithCR ifFalse: [
- tmp _ (Character cr asString) , normalizedTrans.
- normalizedTrans _ tmp.
- ]
- ] ifFalse: [
- transStartsWithCR ifTrue: [
- normalizedTrans _ normalizedTrans allButFirst
- ]
- ]
- ].
- self exportTag: 'msgstr' msg: normalizedTrans.
- stream cr!
Item was removed:
- ----- Method: LanguageEditor>>printTranslationsReportOn: (in category 'reporting') -----
- printTranslationsReportOn: aStream
- "append to aStream a report of the receiver's translations"
- | originalPhrases |
- aStream nextPutAll: '!!';
- nextPutAll: 'translations' translated;
- cr.
-
- originalPhrases := self translator translations keys asSortedCollection.
-
- originalPhrases
- do: [:each |
- aStream
- nextPutAll: ('|{1}|{2}|' format: {self asHtml: each. self
- asHtml: (self translator translate: each)});
- cr].
-
- aStream cr; cr!
Item was removed:
- ----- Method: LanguageEditor>>getTextExportTemplate (in category 'gui methods') -----
- getTextExportTemplate
- Cursor wait
- showWhile: [GetTextExporter2 new exportTemplate] !
Item was removed:
- ----- Method: LanguageEditor>>createUpdatingButtonWording:action:help: (in category 'initialization - toolbar') -----
- createUpdatingButtonWording: wordingSelector action: actionSelector help: helpString
- "create a toolbar for the receiver"
- | button |
- button := (UpdatingSimpleButtonMorph newWithLabel: '-') target: self;
- wordingSelector: wordingSelector;
- actionSelector: actionSelector;
- setBalloonText: helpString translated;
- color: translator defaultBackgroundColor twiceDarker;
- borderWidth: 1;
- borderColor: #raised; cornerStyle: #square.
- ""
- ^ button!
Item was removed:
- ----- Method: LanguageEditor>>selectedTranslation (in category 'accessing') -----
- selectedTranslation
- "answer the selectedTranslation"
- ^ selectedTranslation!
Item was removed:
- ----- Method: GetTextExporter2>>createExtraInformation (in category 'private') -----
- createExtraInformation
- | extras |
- extras := OrderedCollection new.
- #(
- 'Language name as you''d like it to appear in the Languages menu' 'Language-Name'
- 'Scale to apply to font size (2 for twice as large)' 'Font-Scale'
- 'Directionality of language' 'Language-Direction'
- 'Use this if you do not want any of the text to be bolded, for legibility' 'Suppress-Bold'
- 'Font to use on a Windows system' 'Win-Font'
- 'Font to use on a Mac system' 'Mac-Font'
- 'Font to use on a Linux system' 'Linux-Font') pairsDo: [:first :second |
- extras add: (Array with: '' with: first with: second).
- ].
- ^ extras!
Item was removed:
- ----- Method: LanguageEditor>>loadFromFile (in category 'gui methods') -----
- loadFromFile
- | fileName |
- fileName := self selectTranslationFileName.
- fileName isNil
- ifTrue: [""
- self beep.
- ^ self].
- ""
- Cursor wait
- showWhile: [
- self translator loadFromFileNamed: fileName.
- self refreshBoth]!
Item was removed:
- ----- Method: GetTextExporter2>>export:translator:domain: (in category 'private') -----
- export: literals translator: translator domain: domainName
- | fileName |
- "Export a gettext file in a category. literals is a dictionary of keyword -> #(MethodReference...) in the textDomain."
- fileName := self dirNameDomain: domainName translator: translator.
- [stream := FileStream forceNewFileNamed: fileName.
- stream lineEndConvention: #lf.
- stream converter: UTF8TextConverter new.
- self exportHeader: domainName.
- self exportInformation: self createExtraInformation.
- self exportBody: literals translator: translator]
- ensure: [stream close]!
Item was removed:
- ----- Method: LanguageEditor>>createUntranslatedToolbar (in category 'initialization - toolbar') -----
- createUntranslatedToolbar
- "create a toolbar for the receiver"
- | toolbar |
- toolbar := self createRow.
- ""
- toolbar
- addMorphBack: (self
- createUpdatingButtonWording: #untranslatedFilterWording
- action: #filterUntranslated
- help: 'Filter the untranslated list.').
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- ""
- toolbar
- addMorphBack: (self
- createButtonLabel: 'search'
- action: #searchUntranslated
- help: 'Search for a untranslated phrase containing...').
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- toolbar
- addMorphBack: (self
- createButtonLabel: 'remove'
- action: #removeUntranslated
- help: 'Remove the selected untranslated phrease. If none is selected, ask for the one to remove.').
- ""
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- toolbar
- addMorphBack: (self
- createButtonLabel: 'translate'
- action: #translate
- help: 'Translate the selected untranslated phrase or a new phrase').
- ""
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- toolbar
- addMorphBack: (self
- createButtonLabel: 'where'
- action: #browseMethodsWithUntranslated
- help: 'Launch a browser on all methods that contain the phrase as a substring of any literal String.').
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- toolbar
- addMorphBack: (self
- createButtonLabel: 'r-unused'
- action: #removeUntranslatedButUnusedStrings
- help: 'Remove all the strings that are not used by the system').
- ^ toolbar!
Item was removed:
- ----- Method: LanguageEditor class>>ensureVisibilityOfWindow: (in category 'private') -----
- ensureVisibilityOfWindow: aWindow
- "private - activate the window"
- | |
- aWindow expand.
- aWindow comeToFront.
- ""
- aWindow
- right: (aWindow right min: World right).
- aWindow
- bottom: (aWindow bottom min: World bottom).
- aWindow
- left: (aWindow left max: World left).
- aWindow
- top: (aWindow top max: World top).
- ""
- aWindow flash; flash!
Item was removed:
- ----- Method: LanguageEditor>>withUnboundModelDo: (in category 'private') -----
- withUnboundModelDo: aBlock
- "Private - Evaluate aBlock with the receiver temporary
- unbound from the model.
-
- Useful to perform a batch of modifications to the model
- without updating the view."
- | formerModel |
- formerModel := self model.
- self model: nil.
- [aBlock value: formerModel]
- ensure: [self model: formerModel]!
Item was removed:
- ----- Method: TextDomainManager classSide>>defaultDomain: (in category 'accessing') -----
- defaultDomain: aDomainName
- defaultDomain := aDomainName!
Item was removed:
- ----- Method: LanguageEditor>>checkPhrase:translation: (in category 'private') -----
- checkPhrase: phraseString translation: translationString
- ^nil!
Item was removed:
- ----- Method: LanguageEditor>>createStatusbar (in category 'initialization - statusbar') -----
- createStatusbar
- "create the statusbar for the receiver"
- | statusbar |
- statusbar := self createRow.
- statusbar addMorph: ((UpdatingStringMorph on: self selector: #status) growable: true;
- useStringFormat;
- hResizing: #spaceFill;
- stepTime: 2000).
- ^ statusbar!
Item was removed:
- ----- Method: GetTextExporter2 classSide>>exportTemplate (in category 'utilities') -----
- exportTemplate
- "GetTextExporter2 exportTemplate"
- self new exportTemplate.!
Item was removed:
- ----- Method: GetTextExporter2>>exportTag:singleLine: (in category 'private') -----
- exportTag: tag singleLine: aString
- stream nextPutAll: tag.
- stream space.
- stream nextPut: $".
- stream
- nextPutAll: (self formatString: aString).
- stream nextPut: $".
- stream cr!
Item was removed:
- ----- Method: LanguageEditor>>newTranslations (in category 'gui methods') -----
- newTranslations
- "private - try to apply the translations as much as possible all
- over the image"
- | result newID |
- result := FillInTheBlank request: 'New locale ID string?' translated initialAnswer: Locale current determineLocaleID isoString.
- result isEmpty
- ifTrue: ["Do nothing"
- ^ self].
- newID := LocaleID isoString: result.
- InternalTranslator
- newLocaleID: (LocaleID isoString: result).
- self class openOn: newID!
Item was removed:
- ----- Method: GetTextExporter>>exportUntranslated (in category 'private-translations') -----
- exportUntranslated
- | keys |
- keys := language untranslated keys asArray sort.
- ProgressInitiationException
- display: 'Exporting untranslated phrases as a gettext file.'
- at: Sensor cursorPoint
- from: 1
- to: keys size
- during: [:bar | 1
- to: keys size
- do: [:index |
- self
- exportPhrase: (keys at: index)
- translation: ''.
- bar value: index]]!
Item was removed:
- ----- Method: LanguageEditor>>perform:orSendTo: (in category 'message handling') -----
- perform: selector orSendTo: otherTarget
- "I wish to intercept and handle selector myself"
- ^ self perform: selector!
Item was removed:
- ----- Method: MOFile>>loadHeader: (in category 'private') -----
- loadHeader: strm
- strm binary.
- magic _ strm uint32.
- magic = 16rDE120495
- ifTrue: [isLittleEndian _ true]
- ifFalse: [
- magic = 16r950412DE
- ifTrue: [isLittleEndian _ false]
- ifFalse: [ self error: 'invalid MO']
- ].
- revision _ self nextInt32From: strm.
- nStrings _ self nextInt32From: strm.
- originalTableOffset _ self nextInt32From: strm.
- translatedTableOffset _ self nextInt32From: strm.
- hashTableSize _ self nextInt32From: strm.
- hashTableOffset _ self nextInt32From: strm.
- !
Item was removed:
- ----- Method: GetTextExporter2>>exportTemplate (in category 'exporting') -----
- exportTemplate
- "GetTextExporter2 new exportTemplate"
- self exportTranslator: nil!
Item was removed:
- ----- Method: LanguageEditor>>translationsMenu: (in category 'gui methods') -----
- translationsMenu: aMenu
- ^ aMenu add: 'remove (x)' translated action: #removeTranslation;
- add: 'where (E)' translated action: #browseMethodsWithTranslation;
- add: 'select all' translated action: #selectAllTranslation;
- add: 'deselect all' translated action: #deselectAllTranslation;
- add: 'select changed keys' translated action: #selectNewerKeys;
- add: 'export selection' translated action: #codeSelectedTranslation;
- add: 'export selection in do-it form' translated action: #codeSelectedTranslationAsMimeString;
- add: 'reset changed keys' translated action: #resetNewerKeys;
- yourself!
Item was removed:
- ----- Method: LanguageEditor>>translatePhrase: (in category 'gui methods') -----
- translatePhrase: aString
- "translate aString"
- | translation |
- translation := FillInTheBlank
- multiLineRequest: 'translation for: ' translated , '''' , aString , ''''
- centerAt: Sensor cursorPoint
- initialAnswer: aString
- answerHeight: 200.
- ""
- (translation isNil
- or: [translation = ''])
- ifTrue: [""
- self beep.
- ^ self].
- ""
- self phrase: aString translation: translation!
Item was removed:
- ----- Method: MOFile>>loadStrings:pointers: (in category 'private') -----
- loadStrings: strm pointers: table
- ^self loadStrings: strm pointers: table encoding: nil languageEnvironment: nil
- !
Item was removed:
- ----- Method: GetTextInterchange>>language: (in category 'accessing') -----
- language: translator
- language _ translator!
Item was removed:
- ----- Method: LanguageEditor>>printUntranslatedReportOn: (in category 'reporting') -----
- printUntranslatedReportOn: aStream
- "append to aStream a report of the receiver's translations"
- aStream nextPutAll: '!!';
- nextPutAll: 'not translated' translated;
- cr.
-
- self untranslated asSortedCollection
- do: [:each |
- aStream
- nextPutAll: ('|{1}|' format: {self asHtml: each});
- cr].
-
- aStream cr; cr!
Item was removed:
- ----- Method: MOFile>>loadHashTable: (in category 'experimental') -----
- loadHashTable: strm
- | entry |
- hashTable _ IntegerArray ofSize: hashTableSize.
- strm binary.
- strm position: hashTableOffset.
- 1 to: hashTableSize do: [:index |
- entry _ self nextInt32From: strm.
- hashTable at: index put: entry.
- ]!
Item was removed:
- ----- Method: MOFile>>testSearchByHash (in category 'experimental') -----
- testSearchByHash
- InternalTranslator allKnownPhrases
- do: [:each |
- self searchByHash: each
- ].
- !
Item was removed:
- ----- Method: LanguageEditor>>initializeStatusbar (in category 'initialization - statusbar') -----
- initializeStatusbar
- "initialize the receiver's statusbar"
- self
- addMorph: self createStatusbar
- frame: (0 @ 0.93 corner: 1 @ 1)!
Item was removed:
- ----- Method: LanguageEditor>>filterUntranslated: (in category 'gui methods') -----
- filterUntranslated: aString
- | filter |
- filter := aString
- ifNil: [''].
- ""
- untranslatedFilter := filter.
- self refreshUntranslated!
Item was removed:
- ----- Method: LanguageEditor>>untranslatedMenu: (in category 'gui methods') -----
- untranslatedMenu: aMenu
- ^ aMenu add: 'remove' translated action: #removeUntranslated;
- add: 'translate (t)' translated action: #translate;
- add: 'where (E)' translated action: #browseMethodsWithUntranslated;
- yourself!
Item was removed:
- ----- Method: GetTextExporter2 classSide>>exportAll (in category 'utilities') -----
- exportAll
- "GetTextExporter2 exportAll"
- self new exportTemplate.
- InternalTranslator availableLanguageLocaleIDs
- do: [:each | self new exportTranslator: each translator]!
Item was removed:
- ----- Method: GetTextExporter>>export: (in category 'exporting') -----
- export: aLanguage
- language := aLanguage.
- [stream := FileStream forceNewFileNamed: self defaultFileName.
- stream lineEndConvention: #lf.
- stream converter: UTF8TextConverter new.
- self exportHeader.
- self exportTranslations.
- self exportUntranslated]
- ensure: [stream close]!
Item was removed:
- ----- Method: LanguageEditor>>removeTranslation (in category 'gui methods') -----
- removeTranslation
- "remove the selected translation"
- | translation |
- self selectedTranslation isZero
- ifTrue: [""
- self beep.
- self inform: 'select the translation to remove' translated.
- ^ self].
- ""
- translation := self translations at: self selectedTranslation.
- ""
- (self
- confirm: ('Removing "{1}".
- Are you sure you want to do this?' translated format: {translation}))
- ifFalse: [^ self].
- ""
- self translator removeTranslationFor: translation.
- self refreshBoth!
Item was removed:
- ----- Method: LanguageEditor>>removeTranslatedButUnusedStrings (in category 'stef') -----
- removeTranslatedButUnusedStrings
- (self confirm: 'Are you sure that you want to remove unused strings?' translated)
- ifFalse: [^ self].
- translationsList getList
- do: [:each |
- | timesUsed |
- timesUsed := self numberOfTimesStringIsUsed: each.
- Transcript show: each.
- Transcript show: timesUsed printString;
- cr.
- timesUsed isZero
- ifTrue: [self translator removeTranslationFor: each]]!
Item was removed:
- ----- Method: LanguageEditor>>asHtml: (in category 'reporting') -----
- asHtml: aString
- | stream |
- stream := String new writeStream.
-
- aString
- do: [:each |
- each caseOf: {
- [Character cr] -> [stream nextPutAll: '<br>'].
- [$&] -> [stream nextPutAll: '&'].
- [$<] -> [stream nextPutAll: '<'].
- [$>] -> [stream nextPutAll: '>'].
- [$*] -> [stream nextPutAll: '☆'].
- [$@] -> [stream nextPutAll: '&at;']}
- otherwise: [stream nextPut: each]].
-
- ^ stream contents!
Item was removed:
- ----- Method: GetTextExporter2>>stream (in category 'accessing') -----
- stream
- ^ stream!
Item was removed:
- ----- Method: LanguageEditor>>translate (in category 'gui methods') -----
- translate
- "translate a phrase"
- | phrase |
- phrase := self phraseToTranslate.
- ""
- (phrase isNil
- or: [phrase = ''])
- ifTrue: [""
- self beep.
- ^ self].
- ""
- self translatePhrase: phrase.
- self refreshBoth!
Item was removed:
- ----- Method: LanguageEditor>>update: (in category 'updating') -----
- update: aSymbol
- "Receive a change notice from an object of whom the receiver
- is a dependent."
- super update: aSymbol.
- ""
- aSymbol == #untranslated
- ifTrue: [self refreshUntranslated].
- aSymbol == #translations
- ifTrue: [self refreshTranslations]!
Item was removed:
- ----- Method: MOFile classSide>>initialize (in category 'class initialization') -----
- initialize
- Cr := Character cr.
- Lf := Character lf.
- !
Item was removed:
- ----- Method: LanguageEditor>>selectAllTranslation (in category 'gui methods') -----
- selectAllTranslation
- selectedTranslations := (1 to: self translations size) asIdentitySet.
- self changed: #allSelections!
Item was removed:
- ----- Method: GetTextExporter2 classSide>>keys (in category 'utilities') -----
- keys
- | categories |
- categories := Dictionary new.
- GetTextExporter2 new appendTranslations: categories.
- ^ categories values
- inject: Set new
- into: [:set :next | set addAll: next keys;
- yourself]!
Item was removed:
- ----- Method: LanguageEditor class>>on: (in category 'instance creation') -----
- on: localeID
- "answer an instance of the receiver on aLanguage"
- ^ self new
- initializeOn: (InternalTranslator cachedTranslations
- at: localeID
- ifAbsent: [self
- error: ('Translator for {1} is not found' translated format: {localeID})])!
Item was removed:
- ----- Method: GetTextExporter2>>exportBody:translator: (in category 'file out') -----
- 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: (self translationFor: msgid in: translator)]!
Item was removed:
- ----- Method: MOFile>>load:localeID: (in category 'public') -----
- load: aFileName localeID: id
- "all of original/translated strings are loaded.
- but conversion of translation string (in utf-8 bytestring) to Squeak format will be defered.
- original-string/index pairs are registerd to Dictionary on load time.
- hash search can't be used"
- | strm originalTable translatedTable |
- localeID _ id.
- strm_ FileStream readOnlyFileNamed: aFileName.
- fileName _ aFileName.
- [
- self loadHeader: strm.
- originalTable _ self loadStringPointers: strm
- offset: originalTableOffset.
-
- originalStrings _ self loadStrings: strm
- pointers: originalTable.
-
- translatedTable _ self loadStringPointers: strm
- offset: translatedTableOffset.
-
- translatedStrings _ self loadStrings: strm
- pointers: translatedTable.
-
- translations _ Dictionary new: nStrings * 2. "make too enough room to avoid #grow"
- 1 to: nStrings do: [:index |
- | key |
- key _ originalStrings at: index.
- translations at: key put: index.
- ].
- originalStrings _ nil.
- ] ensure: [strm close].!
Item was removed:
- ----- Method: TextDomainManager classSide>>updateDomainOfAllMethodsWithTranslations (in category 'private') -----
- updateDomainOfAllMethodsWithTranslations
- self allMethodsWithTranslations do: [:each|
- self updateDomainOfMethod: each
- ]!
Item was removed:
- ----- Method: MOFile>>searchByDictionary: (in category 'public') -----
- searchByDictionary: aString
- | index |
- index _ translations at: aString ifAbsent: [^nil].
- ^self translatedString: index
-
- !
Item was removed:
- ----- Method: LanguageEditor>>refreshTranslations (in category 'updating') -----
- refreshTranslations
- "refresh the translations panel"
- self selectedTranslation: 0.
- translations := nil.
- self changed: #translations.
- !
Item was removed:
- ----- Method: TextDomainManager classSide>>domainForClass: (in category 'accessing') -----
- domainForClass: aClass
- ^'etoys'!
Item was removed:
- ----- Method: MOFile>>fileName: (in category 'public') -----
- fileName: path
- fileName _ path!
Item was removed:
- ----- Method: LanguageEditor>>getTextImportAFile (in category 'gui methods') -----
- getTextImportAFile
- | result |
- result := (StandardFileMenu new pattern: '*.po';
-
- oldFileFrom: (FileDirectory default directoryNamed: 'po')) startUpWithCaption: 'Select a File:' translated.
- result
- ifNil: [^ self].
- self
- withUnboundModelDo: [:trans | Cursor wait
- showWhile: [GetTextImporter new
- import: trans
- fileNamed: (result directory fullNameFor: result name)]]!
Item was removed:
- ----- Method: TextDomainManager classSide>>domainForPackage: (in category 'accessing') -----
- domainForPackage: aPackageInfo
- "Package names and text domains are synonyms now"
- ^aPackageInfo name!
Item was removed:
- Object subclass: #GetTextInterchange
- instanceVariableNames: 'language stream'
- classVariableNames: ''
- poolDictionaries: ''
- category: 'GetText-Editor'!
Item was removed:
- ----- Method: LanguageEditor>>status (in category 'gui methods') -----
- status
- "answer a status string"
- | translationsSize untranslatedSize |
- translationsSize := self translator translations size.
- untranslatedSize := self translator untranslated size.
- ^ '| {1} phrases | {2} translated | {3} untranslated |' translated format: {translationsSize + untranslatedSize. translationsSize. untranslatedSize}!
Item was removed:
- ----- Method: LanguageEditor>>phrase:translation: (in category 'gui methods') -----
- phrase: phraseString translation: translationString
- "set the models's translation for phraseString"
- self translator phrase: phraseString translation: translationString.
- self refreshBoth.
-
- newerKeys add: phraseString.
- !
Item was removed:
- ----- Method: LanguageEditor>>createRow (in category 'initialization - toolbar') -----
- createRow
- "create a row"
- | row |
- row := AlignmentMorph newRow.
- row layoutInset: 3;
- wrapCentering: #center;
- cellPositioning: #leftCenter.
- ""
- ^ row!
Item was removed:
- ----- Method: LanguageEditor>>browseMethodsWithTranslation (in category 'gui methods') -----
- browseMethodsWithTranslation
- | translation |
- self selectedTranslation isZero
- ifTrue: [""
- self beep.
- self inform: 'select the translation to look for' translated.
- ^ self].
- ""
- translation := self translations at: self selectedTranslation.
- self systemNavigation browseMethodsWithLiteral: translation!
Item was removed:
- ----- Method: LanguageEditor>>removeUntranslated (in category 'gui methods') -----
- removeUntranslated
- "remove the selected untranslated phrase"
- | untrans |
- self selectedUntranslated isZero
- ifTrue: [""
- self beep.
- self inform: 'select the untranslated phrase to remove' translated.
- ^ self].
- ""
- untrans := self untranslated at: self selectedUntranslated.
- ""
- (self
- confirm: ('Removing "{1}".
- Are you sure you want to do this?' translated format: {untrans}))
- ifFalse: [^ self].
- ""
- self translator removeUntranslated: untrans!
Item was removed:
- ----- Method: LanguageEditor>>untranslated (in category 'accessing') -----
- untranslated
- "answer the translator's untranslated phrases"
-
-
- | all filterString |
- untranslated ifNotNil: [^ untranslated].
- all := self translator untranslated.
- ""
- filterString := self untranslatedFilter.
- ""
- filterString isEmpty
- ifFalse: [all := all
- select: [:each | ""
- ('*' , filterString , '*' match: each)
- or: ['*' , filterString , '*'
- match: (self translator translate: each)]]].
- ""
- ^ untranslated _ all asSortedCollection asArray!
Item was removed:
- ----- Method: TextDomainManager classSide>>initialize (in category 'class initialization') -----
- initialize
- " TextDomainManager initialize "
- self defaultDomain: 'Etoys'; clearAllDomains!
Item was removed:
- ----- Method: TextDomainManager classSide>>updateDomainOfMethod: (in category 'private') -----
- updateDomainOfMethod: aCompiledMethod
- "First it looks for the package of the method reference (using
- the PackageOrganizer: deadly slow). If the method doesn't
- belong to any package it uses the default domain. Finally it
- stores the text domain of the method using a method
- property, this way we gain performance the next time we
- translate the same method because we avoid the use of
- PackageOrganizer. Have I mentioned it is really slow? :)"
- | package |
- package := PackageOrganizer default
- packageOfMethod: aCompiledMethod methodReference
- ifNone: [].
- ^ aCompiledMethod
- propertyValueAt: self textDomainProperty
- put: (package isNil
- ifTrue: [TextDomainManager defaultDomain]
- ifFalse: [package name])!
Item was removed:
- ----- Method: LanguageEditor>>okToChange (in category 'updating') -----
- okToChange
- "Allows a controller to ask this of any model"
- self selectedTranslation isZero
- ifTrue: [^ true].
- ""
- translationText hasUnacceptedEdits
- ifFalse: [^ true].
- ^ (CustomMenu confirm: 'Discard the changes to currently selected translated phrase?' translated)
- and: [""
- translationText hasUnacceptedEdits: false.
- true]!
Item was removed:
- ----- Method: GetTextExporter2>>appendStringReceivers:into: (in category 'private') -----
- appendStringReceivers: aSymbol into: domains
- | literals references domainName methodReference keywords found |
-
- found := TranslatedReceiverFinder new stringReceiversWithContext: aSymbol.
- found do: [ :assoc |
- methodReference := assoc key.
- keywords := assoc value.
- domainName _ self getTextDomainForPackage:
- (PackageOrganizer default packageOfMethod: methodReference ifNone: [TextDomainManager defaultDomain]).
- literals _ domains at: domainName ifAbsentPut: [Dictionary new].
- keywords do: [ :literal |
- references _ literals at: literal ifAbsentPut: [OrderedCollection new].
- references add: methodReference.
- ].
- ].
- !
Item was removed:
- ----- Method: LanguageEditor>>selectTranslationFileName (in category 'gui methods') -----
- selectTranslationFileName
- "answer a file with a translation"
- | file |
- file := (StandardFileMenu oldFileMenu: FileDirectory default withPattern: '*.translation')
- startUpWithCaption: 'Select the file...' translated.
- ^ file isNil
- ifFalse: [file directory fullNameFor: file name]!
Item was removed:
- ----- Method: MOFile>>load4:localeID: (in category 'experimental') -----
- load4: aFileName localeID: id
- "CASE4:
- all of strings are loaded.
- loading and conversion of translation strings to Squeak format is executed on initialization time.
- only hash search can be used"
- | strm originalTable translatedTable |
- localeID _ id.
- strm_ FileStream readOnlyFileNamed: aFileName.
- fileName _ aFileName.
- [
- self loadHeader: strm.
- self loadHashTable: strm.
- originalTable _ self loadStringPointers: strm
- offset: originalTableOffset.
-
- originalStrings _ self loadStrings: strm
- pointers: originalTable.
-
- translatedTable _ self loadStringPointers: strm
- offset: translatedTableOffset.
-
- translatedStrings _ self loadStrings: strm
- pointers: translatedTable
- encoding: 'utf-8'
- languageEnvironment: (Locale localeID: localeID) languageEnvironment .
- ] ensure: [strm close].!
Item was removed:
- ----- Method: LanguageEditor class>>checkMethods (in category 'private') -----
- checkMethods
- ^CheckMethods ifNil: [CheckMethods := self initCheckMethods]!
Item was removed:
- Object subclass: #MOFile
- instanceVariableNames: 'localeID fileName isLittleEndian magic revision nStrings originalTableOffset translatedTableOffset hashTableSize hashTableOffset hashTable originalStrings translatedStrings translations'
- classVariableNames: 'Cr Lf'
- poolDictionaries: ''
- category: 'GetText-Localization'!
-
- !MOFile commentStamp: '<historical>' prior: 0!
- Wrapper for MO file of gettext.
- Known limitation:
- currently don't support prural form.
- translation strings have to be encoded in utf-8.
-
- Implementation notes:
- Testing on XO showed emulation of hash search without plugin + on demand loading is slow.
- The test also showed conversion of utf8 string to Squeak's String is really slow (especially for non-latin language).
- so in this version, all of original/translated strings are loaded on initiaization,
- but "translated strings" is left as ByteString on loading time, to reduce loading time.
- After that the translated string is converted on demand.
- !
Item was removed:
- ----- Method: LanguageEditor>>selectedUntranslated: (in category 'accessing') -----
- selectedUntranslated: anInteger
- "change the selectedUntranslated"
- selectedUntranslated := anInteger.
- ""
- self changed: #selectedUntranslated!
Item was removed:
- ----- Method: LanguageEditor>>translationsFilter (in category 'accessing') -----
- translationsFilter
- ^translationsFilter ifNil:['']!
Item was removed:
- ----- Method: GetTextExporter2>>formatReplacements (in category 'private') -----
- formatReplacements
- | replacements |
- replacements := OrderedCollection new.
- replacements add: '\' -> '\\'.
- replacements add: String cr -> '\n'.
- replacements add: String tab -> '\t'.
- replacements add: '"' -> '\"'.
- ^ replacements!
Item was removed:
- ----- Method: LanguageEditor>>searchTranslation: (in category 'gui methods') -----
- searchTranslation: aString
- | results index |
- results := self translations
- select: [:each | ""
- ('*' , aString , '*' match: each)
- or: ['*' , aString , '*' match: (self translator translate: each)]].
- ""
- results isEmpty
- ifTrue: [""
- self inform: 'no matches for' translated , ' ''' , aString , ''''.
- ^ self].
- ""
- results size = 1
- ifTrue: [""
- self selectTranslationPhrase: results first.
- ^ self].
- ""
- index := (PopUpMenu
- labelArray: (results
- collect: [:each | ""
- (each copy replaceAll: Character cr with: $\)
- , ' -> '
- , ((self translator translate: each) copy replaceAll: Character cr with: $\)]))
- startUpWithCaption: 'select the translation...' translated.
- ""
- index isZero
- ifTrue: [""
- self beep.
- ^ self].
- ""
- self
- selectTranslationPhrase: (results at: index)!
Item was removed:
- ----- Method: LanguageEditor class>>initCheckMethods (in category 'initialize-release') -----
- initCheckMethods
- "LanguageEditor initCheckMethods"
-
- | registry |
- registry := Dictionary new.
- registry
- at: 'es' put: #checkSpanishPhrase:translation:;
- yourself.
- ^registry!
Item was removed:
- ----- Method: LanguageEditor>>phraseToTranslate (in category 'gui methods') -----
- phraseToTranslate
- "answer a phrase to translate. use the selected untranslated phrase or ask for a new one"
- ^ self selectedUntranslated isZero
- ifTrue: [FillInTheBlank
- multiLineRequest: 'new phrase to translate' translated
- centerAt: Sensor cursorPoint
- initialAnswer: ''
- answerHeight: 200]
- ifFalse: [self untranslated at: self selectedUntranslated]!
Item was removed:
- ----- Method: LanguageEditor>>filterUntranslated (in category 'gui methods') -----
- filterUntranslated
- | filter |
- filter := FillInTheBlank request: 'filter with
- (empty string means no-filtering)' translated initialAnswer: self untranslatedFilter.
- ""
- self filterUntranslated: filter!
Item was removed:
- ----- Method: LanguageEditor>>report (in category 'gui methods') -----
- report
- self reportString openInWorkspaceWithTitle: 'report' translated!
Item was removed:
- ----- Method: LanguageEditor>>createTranslationsToolbar (in category 'initialization - toolbar') -----
- createTranslationsToolbar
- "create a toolbar for the receiver"
- | toolbar |
- toolbar := self createRow.
- ""
- toolbar
- addMorphBack: (self
- createUpdatingButtonWording: #translationsFilterWording
- action: #filterTranslations
- help: 'Filter the translations list.').
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- ""
- toolbar
- addMorphBack: (self
- createButtonLabel: 'search'
- action: #searchTranslation
- help: 'Search for a translation containing...').
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- toolbar
- addMorphBack: (self
- createButtonLabel: 'remove'
- action: #removeTranslation
- help: 'Remove the selected translation. If none is selected, ask for the one to remove.').
- ""
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- toolbar
- addMorphBack: (self
- createButtonLabel: 'where'
- action: #browseMethodsWithTranslation
- help: 'Launch a browser on all methods that contain the phrase as a substring of any literal String.').
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- toolbar
- addMorphBack: (self
- createButtonLabel: 'r-unused'
- action: #removeTranslatedButUnusedStrings
- help: 'Remove all the strings that are not used by the system').
- toolbar addTransparentSpacerOfSize: 5 @ 0.
- toolbar
- addMorphBack: (self
- createButtonLabel: 'add '
- action: #addTranslation
- help: 'Add a new phrase').
-
- ^ toolbar!
Item was removed:
- ----- Method: LanguageEditor>>codeSelectedTranslation (in category 'gui methods') -----
- codeSelectedTranslation
- | keys code |
- keys := selectedTranslations
- collect: [:key | self translations at: key].
- code := String
- streamContents: [:aStream | self translator fileOutOn: aStream keys: keys withBOM: false].
- (StringHolder new contents: code)
- openLabel: 'exported codes' translated!
Item was removed:
- ----- Method: GetTextExporter2>>exportTag:msg: (in category 'private') -----
- exportTag: tag msg: aString
- | pos end line |
- (aString indexOf: Character cr)
- = 0
- ifTrue: [self exportTag: tag singleLine: aString]
- ifFalse: [self exportTag: tag singleLine: ''.
- pos := 1.
- end := 0.
- [end < aString size]
- whileTrue: [end := aString indexOf: Character cr startingAt: pos.
- end = 0
- ifTrue: [end := aString size].
- line := aString copyFrom: pos to: end.
- stream nextPut: $";
-
- nextPutAll: (self formatString: line);
- nextPut: $";
- cr.
- pos := end + 1]]!
Item was removed:
- ----- Method: LanguageEditor>>selectNewerKeys (in category 'gui methods') -----
- selectNewerKeys
-
- | index |
- self deselectAllTranslation.
- newerKeys do: [:k |
- index _ self translations indexOf: k ifAbsent: [0].
- index > 0 ifTrue: [
- self selectedTranslationsAt: index put: true
- ].
- ].
- !
Item was removed:
- ----- Method: GetTextExporter2>>currentDateAndTime (in category 'private') -----
- currentDateAndTime
- ^ String
- streamContents: [:aStream |
- aStream nextPutAll: Date today yyyymmdd;
- space.
- Time now
- print24: true
- showSeconds: false
- on: aStream.
- aStream nextPutAll: '-0000']!
Item was removed:
- ----- Method: MOFile>>load1:localeID: (in category 'experimental') -----
- load1: aFileName localeID: id
- "CASE1:
- all of strings are loaded.
- translation strings are converted to Squeak format on load time.
- original-string/index pairs are registerd to Dictionary on load time.
- hash search can't be used"
- | strm originalTable translatedTable |
- localeID _ id.
- strm_ FileStream readOnlyFileNamed: aFileName.
- fileName _ aFileName.
- [
- self loadHeader: strm.
- originalTable _ self loadStringPointers: strm
- offset: originalTableOffset.
-
- originalStrings _ self loadStrings: strm
- pointers: originalTable.
-
- translatedTable _ self loadStringPointers: strm
- offset: translatedTableOffset.
-
- translatedStrings _ self loadStrings: strm
- pointers: translatedTable
- encoding: 'utf8'
- languageEnvironment: (Locale localeID: localeID) languageEnvironment .
-
- translations _ Dictionary new.
- 1 to: nStrings do: [:index |
- | key |
- key _ originalStrings at: index.
- translations at: key put: index.
- ].
- originalTable _ nil.
- ] ensure: [strm close].!
Item was removed:
- ----- Method: LanguageEditor>>checkSpanishPhrase:translation: (in category 'private') -----
- checkSpanishPhrase: phraseString translation: translationString
- "check the translation and aswer a string with a comment or a
- nil meaning no-comments"
- | superResult |
- superResult := self checkPhrase: phraseString translation: translationString.
- superResult isNil
- ifFalse: [^ superResult].
- "For some reason, MCInstaller couldn't read Spanish character. "
- "((translationString includes: $?)
- and: [(translationString includes: $¿) not])
- ifTrue: [^ '¿Olvidó el signo de pregunta?'].
- ((translationString includes: $!!)
- and: [(translationString includes: $¡) not])
- ifTrue: [^ '¿Olvidó el signo de admiración?'].
- "
- ^ nil
- !
Item was removed:
- ----- Method: MOFile>>translatedString: (in category 'private') -----
- translatedString: index
- "KNOWN PROBLEM: conversion is executed everytimes this method called"
- | str |
- str _ translatedStrings at: index.
-
- ^str utf8ToSqueak applyLanguageInfomation: (Locale localeID: localeID) languageEnvironment.
- !
Item was removed:
- ----- Method: LanguageEditor>>getTextImportAll (in category 'gui methods') -----
- getTextImportAll
- self
- withUnboundModelDo: [:trans | Cursor wait
- showWhile: [GetTextImporter import: trans allDirectory: FileDirectory default]].
- self refreshBoth!
Item was removed:
- ----- Method: TextDomainManager classSide>>defaultDomain (in category 'accessing') -----
- defaultDomain
- "I'm not sure we still need a default domain, AFAIK the default domain will only be used when no domain is found. In that case, wouldn't it be better to just look for a translation in all domains?"
- ^defaultDomain!
Item was removed:
- ----- Method: LanguageEditor>>initializeNewerKeys (in category 'initialization') -----
- initializeNewerKeys
-
- newerKeys _ Set new.
- !
Item was removed:
- ----- Method: GetTextExporter>>exportHeader (in category 'private-headers') -----
- exportHeader
- self exportTag: 'msgid' msg: ''.
- self exportTag: 'msgstr' msg: ''.
- self createHeaders
- do: [:each | self exportHeaderLineKey: each key value: each value].
- stream cr; cr!
Item was removed:
- SystemWindow subclass: #LanguageEditor
- instanceVariableNames: 'translator translations untranslated selectedTranslation selectedTranslations selectedUntranslated translationsList untranslatedList translationText translationsFilter untranslatedFilter newerKeys'
- classVariableNames: 'CheckMethods'
- poolDictionaries: ''
- category: 'GetText-Editor'!
-
- !LanguageEditor commentStamp: 'dgd 11/16/2003 15:02' prior: 0!
- Editor for Babel's languages.
-
- Open it from
-
- World Menu >> open... >> Language Editor (to open on default language)
- World Menu >> open... >> Language Editor for... (to choose the language)
-
- Or click:
-
- LanguageEditor openOnDefault.
- LanguageEditor open.
-
- See http://swiki.agro.uba.ar/small_land/191 for documentation
- !
Item was removed:
- ----- Method: GetTextExporter2>>getTextDomainForPackage: (in category 'as yet unclassified') -----
- getTextDomainForPackage: aPackageInfo
- ^TextDomainManager domainForPackage: aPackageInfo!
Item was removed:
- ----- Method: GetTextInterchange>>stream: (in category 'accessing') -----
- stream: aStream
- stream _ aStream!
Item was removed:
- Object subclass: #GetTextExporter2
- instanceVariableNames: 'stream'
- classVariableNames: ''
- poolDictionaries: ''
- category: 'GetText-Editor'!
-
- !GetTextExporter2 commentStamp: '<historical>' prior: 0!
- Export translations to gettext format divided into categories.
-
- "Export gettext template files"
- GetTextExporter2 new exportTemplate.
-
- "Export translation files for current locale"
- GetTextExporter2 new exportTranslator: (InternalTranslator newLocaleID: LocaleID current).
-
- "Export all gettext template and po files."
- GetTextExporter2 exportAll.
-
- "To register a class category as a new domain"
- TextDomainManager registerClassCategory: 'Morphic-Books' domain: 'Book'.
- "Remove a class category"
- TextDomainManager unregisterClassCategory: 'Morphic-Books'.!
Item was removed:
- ----- Method: TextDomainManager classSide>>textDomainProperty (in category 'private') -----
- textDomainProperty
- ^#textDomain!
Item was removed:
- ----- Method: LanguageEditor>>selectedTranslation: (in category 'accessing') -----
- selectedTranslation: anInteger
- "change the receiver's selectedTranslation"
- selectedTranslation := anInteger.
- ""
- self changed: #selectedTranslation.
- self changed: #translation!
Item was removed:
- ----- Method: LanguageEditor>>searchTranslation (in category 'gui methods') -----
- searchTranslation
- | search |
- search := FillInTheBlank request: 'search for' translated initialAnswer: ''.
- (search isNil
- or: [search isEmpty])
- ifTrue: [""
- self beep.
- ^ self].
- ""
- self searchTranslation: search!
Item was removed:
- ----- Method: LanguageEditor>>removeUntranslatedButUnusedStrings (in category 'stef') -----
- removeUntranslatedButUnusedStrings
- (self confirm: 'Are you sure that you want to remove unused strings?' translated)
- ifFalse: [^ self].
- untranslatedList getList
- do: [:each |
- | timesUsed |
- timesUsed := self numberOfTimesStringIsUsed: each.
- Transcript show: each.
- Transcript show: timesUsed printString;
- cr.
- timesUsed isZero
- ifTrue: [self translator removeUntranslated: each]].
-
- self refreshUntranslated.
- !
Item was removed:
- ----- Method: MOFile>>hashPjw: (in category 'experimental') -----
- hashPjw: aString
- "So called `hashpjw' function by P.J. Weinberger
- [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
- 1986, 1987 Bell Telephone Laboratories, Inc.] "
- | stringSize hash g |
- stringSize _ aString size.
- hash _ 0.
- 1 to: stringSize do: [:pos |
- hash _ hash bitShift: 4.
- hash _ hash + ((aString at: pos) asInteger).
- g _ hash bitAnd: 16rF0000000.
- g = 0 ifFalse: [
- hash _ hash bitXor: (g bitShift: -24).
- hash _ hash bitXor: g.
- ]
- ].
- ^hash.
- !
Item was removed:
- ----- Method: LanguageEditor>>resetNewerKeys (in category 'gui methods') -----
- resetNewerKeys
-
- self initializeNewerKeys.
- !
Item was removed:
- ----- Method: GetTextExporter2>>exportHeader: (in category 'private') -----
- exportHeader: domainName
- | headers |
- self exportTag: 'msgid' msg: ''.
- self exportTag: 'msgstr' msg: ''.
- headers := self createHeaders.
- headers add: 'X-Etoys-Domain' -> domainName.
- headers do: [:each | self exportHeaderLineKey: each key value: each value].
- stream cr; cr!
Item was removed:
- ----- Method: GetTextExporter2>>appendVocabularies: (in category 'private') -----
- appendVocabularies: domains
- | literalsForDomain references domainName methodReference |
-
- EToyVocabulary allPhrasesWithContextToTranslate do: [ :r |
- methodReference := (MethodReference new setStandardClass: (r second) methodSymbol: (r third)).
- "domainName _ self getTextDomainForPackage: (PackageOrganizer default packageOfMethod: methodReference)".
- domainName := 'Etoys-Tiles'.
- literalsForDomain _ domains at: domainName ifAbsentPut: [Dictionary new].
- r fourth do: [ :literal |
- references _ literalsForDomain at: literal ifAbsentPut: [OrderedCollection new].
- references add: methodReference.
- ].
- ].
- !
Item was removed:
- ----- Method: TextDomainManager classSide>>domainOfMethod: (in category 'accessing') -----
- domainOfMethod: aCompiledMethod
- ^ aCompiledMethod
- propertyValueAt: self textDomainProperty
- ifAbsent: [self updateDomainOfMethod: aCompiledMethod] !
Item was removed:
- ----- Method: TextDomainManager classSide>>clearAllDomains (in category 'private') -----
- clearAllDomains
- SystemNavigation default
- allCompiledMethodDo: [:each | each
- removeProperty: self textDomainProperty
- ifAbsent: []] !
Item was removed:
- ----- Method: LanguageEditor>>selectUntranslatedPhrase: (in category 'gui methods') -----
- selectUntranslatedPhrase: phraseString
- self
- selectedUntranslated: (self untranslated indexOf: phraseString)!
Item was removed:
- ----- Method: MOFile>>originalString: (in category 'private') -----
- originalString: index
- ^originalStrings at: index.
- !
Item was removed:
- ----- Method: LanguageEditor class>>openOn: (in category 'instance creation') -----
- openOn: aLanguage
- "open an instance on aLanguage"
- World submorphs
- do: [:each | ""
- ((each isKindOf: LanguageEditor)
- and: [each translator == aLanguage])
- ifTrue: [""
- self ensureVisibilityOfWindow: each.
- ^ self]].
- ""
- ^ (self on: aLanguage) openInWorld!
Item was removed:
- ----- Method: LanguageEditor>>untranslatedFilterWording (in category 'gui methods') -----
- untranslatedFilterWording
- ^ self untranslatedFilter isEmpty
- ifTrue: ['filter' translated]
- ifFalse: ['filtering: {1}' translated format: {self untranslatedFilter}]!
Item was removed:
- ----- Method: LanguageEditor>>saveToFile (in category 'gui methods') -----
- saveToFile
- "save the translator to a file"
- | fileName |
- fileName := FillInTheBlank request: 'file name' translated initialAnswer: translator localeID isoString , '.translation'.
- (fileName isNil
- or: [fileName isEmpty])
- ifTrue: [""
- self beep.
- ^ self].
- ""
- Cursor wait
- showWhile: [
- self translator saveToFileNamed: fileName]!
Item was removed:
- ----- Method: LanguageEditor>>initializeOn: (in category 'initialization') -----
- initializeOn: aLanguage
- "initialize the receiver on aLanguage"
- ""
- selectedTranslation := 0.
- selectedUntranslated := 0.
- selectedTranslations := IdentitySet new.
- ""
- translator := aLanguage.
- ""
- self model: aLanguage.
- self setLabel: 'Language editor for: ' translated , self translator name.
- ""
- self initializeToolbars.
- self initializePanels.
- self initializeStatusbar.
- self initializeNewerKeys.
- !
Item was removed:
- ----- Method: LanguageEditor>>createButtonLabel:action:help: (in category 'initialization - toolbar') -----
- createButtonLabel: aString action: actionSelector help: helpString
- "create a toolbar for the receiver"
- | button |
- button := SimpleButtonMorph new target: self;
- label: aString translated "font: Preferences standardButtonFont";
- actionSelector: actionSelector;
- setBalloonText: helpString translated;
- color: translator defaultBackgroundColor twiceDarker;
- borderWidth: 2;
- borderColor: #raised.
- ""
- ^ button!
Item was removed:
- ----- Method: MOFile>>loadStringPointers:offset: (in category 'private') -----
- loadStringPointers: strm offset: tableOffset
- "returns tupple {arrayOfOffsetToString arrayOfLengthOfString}"
- | offsetTable lenTable len offset tupple |
- offsetTable _ IntegerArray new: nStrings.
- lenTable _ IntegerArray new: nStrings.
- strm binary.
- strm position: tableOffset.
- 1 to: nStrings do: [:index |
- len _ self nextInt32From: strm.
- offset _ self nextInt32From: strm.
- offsetTable at: index put: offset.
- lenTable at: index put: len.
- ].
- tupple _ Array new: 2.
- tupple at: 1 put: offsetTable.
- tupple at: 2 put: lenTable.
- ^tupple
- !
Item was removed:
- ----- Method: LanguageEditor>>selectedTranslationsAt:put: (in category 'accessing') -----
- selectedTranslationsAt: index put: value
- value = true
- ifTrue: [selectedTranslations add: index]
- ifFalse: [selectedTranslations
- remove: index
- ifAbsent: []]!
Item was removed:
- ----- Method: GetTextExporter2>>formatString: (in category 'private') -----
- formatString: aString
- | result |
- result := aString.
- self formatReplacements
- do: [:each | result := result copyReplaceAll: each key with: each value].
- ^ result!
Item was removed:
- ----- Method: MOFile>>searchByHash: (in category 'experimental') -----
- searchByHash: aString
- | hashValue nstr index incr key |
- hashValue _ self hashPjw: aString.
- incr _ 1 + (hashValue \\ (hashTableSize -2)).
- index _ (hashValue \\ hashTableSize) .
- [ nstr _ (hashTable at: index +1 ).
- nstr = 0 ifTrue: [^nil].
- key _ self originalString: nstr.
- key = aString ifTrue: [^self translatedString: nstr].
- index >= (hashTableSize - incr)
- ifTrue: [index _ index - (hashTableSize - incr) ]
- ifFalse:[index _ index + incr].
- ] doWhileTrue: true.!
Item was removed:
- ----- Method: MOFile>>translateByHash: (in category 'experimental') -----
- translateByHash: aString
- | trans |
- trans _ self searchByHash: aString.
- trans isNil ifTrue: [^aString]
- ifFalse: [^trans].
- !
Item was removed:
- ----- Method: LanguageEditor>>printHeaderReportOn: (in category 'reporting') -----
- printHeaderReportOn: aStream
- "append to aStream a header report of the receiver with swiki
- format"
- aStream nextPutAll: '!!!!';
-
- nextPutAll: ('Language: {1}' translated format: {self translator localeID isoString});
- cr.
-
- aStream nextPutAll: '- ';
-
- nextPutAll: ('{1} translated phrases' translated format: {self translator translations size});
- cr.
-
- aStream nextPutAll: '- ';
-
- nextPutAll: ('{1} untranslated phrases' translated format: {self translator untranslated size});
- cr.
-
- aStream cr; cr!
Item was removed:
- ----- Method: LanguageEditor>>getText (in category 'gui methods') -----
- getText
- | menu |
- menu := MenuMorph new defaultTarget: self.
- ""
- menu
- add: 'gettext template' translated
- target: self
- selector: #getTextExportTemplate.
- menu lastItem setBalloonText: 'exports the translations to gettext separated format.' translated.
- menu
- add: 'gettext export' translated
- target: self
- selector: #getTextExport.
- menu lastItem setBalloonText: 'Exports the translations to GetText format.' translated.
-
- ""
- menu
- add: 'gettext import' translated
- target: self
- selector: #getTextImport.
- menu lastItem setBalloonText: 'Imports the translations from GetText format.' translated.
- ""
- menu popUpInWorld!
More information about the etoys-dev
mailing list