[etoys-dev] Etoys Inbox: System-Richo.12.mcz

commits at source.squeak.org commits at source.squeak.org
Thu May 13 15:10:48 EDT 2010


A new version of System was added to project Etoys Inbox:
http://source.squeak.org/etoysinbox/System-Richo.12.mcz

==================== Summary ====================

Name: System-Richo.12
Author: Richo
Time: 13 May 2010, 4:10:15 pm
UUID: 3188de42-860f-5949-9f9a-12f540c657b7
Ancestors: System-Richo.11

* Removed a lot of stuff used for Localization.
* Modified TextDomainManager to use method properties to store the text domain of each method. This happens in a lazy way. It's also posible to preconfigure the method properties of all methods with translations but it takes forever and it ends up with a Space Low warning (see TextDomainManager class>>updateDomainOfAllMethodsWithTranslations)

=============== Diff against System-Richo.11 ===============

Item was added:
+ ----- 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 changed:
  ----- Method: TextDomainManager classSide>>domainForPackage: (in category 'accessing') -----
  domainForPackage: aPackageInfo
+ "Package names and text domains are synonyms now"
+ 	^aPackageInfo name!
- 	^self domainForPackageNamed: aPackageInfo name!

Item was changed:
  Object subclass: #TextDomainManager
  	instanceVariableNames: ''
  	classVariableNames: 'ClassCategories Classes DefaultDomain DomainInfos LoneClasses Packages'
  	poolDictionaries: ''
  	category: 'System-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 added:
+ ----- Method: TextDomainManager classSide>>domainOfMethod: (in category 'accessing') -----
+ domainOfMethod: aCompiledMethod 
+ 	^ aCompiledMethod
+ 		propertyValueAt: self textDomainProperty
+ 		ifAbsent: [self updateDomainOfMethod: aCompiledMethod] !

Item was added:
+ ----- Method: TextDomainManager classSide>>clearAllDomains (in category 'private') -----
+ clearAllDomains
+ 	SystemNavigation default
+ 		allCompiledMethodDo: [:each | each
+ 				removeProperty: self textDomainProperty
+ 				ifAbsent: []] !

Item was added:
+ ----- Method: TextDomainManager classSide>>updateDomainOfAllMethodsWithTranslations (in category 'private') -----
+ updateDomainOfAllMethodsWithTranslations
+ self allMethodsWithTranslations do: [:each|
+ 	self updateDomainOfMethod: each
+ ]!

Item was changed:
  ----- Method: TextDomainManager classSide>>initialize (in category 'class initialization') -----
  initialize
  	"	TextDomainManager initialize	"
+ 	self defaultDomain: 'Etoys'; clearAllDomains!
- 
- 	ClassCategories _ IdentityDictionary new.
- 	Classes _ IdentityDictionary new.
- 	Packages := Dictionary new.
- 	DomainInfos _ Dictionary new.
- 	self defaultDomain: 'Etoys'.
- 	"self registerClass: #QuickGuideMorph domain: 'quickguides'.
- 	self registerClass: #QuickGuideHolderMorph  domain: 'quickguides'."!

Item was added:
+ ----- Method: TextDomainManager classSide>>textDomainProperty (in category 'private') -----
+ textDomainProperty
+ ^#textDomain!

Item was changed:
  ----- 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!
- 	^DefaultDomain!

Item was added:
+ ----- 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 changed:
  ----- 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!
- 	| domains |
- 	domains _ Set new.
- 	domains addAll: Packages values.
- 	domains add: self defaultDomain.
- 	^domains
- !

Item was changed:
  ----- Method: TextDomainManager classSide>>defaultDomain: (in category 'accessing') -----
  defaultDomain: aDomainName
+ 	defaultDomain := aDomainName!
- 	DefaultDomain _ aDomainName!

Item was removed:
- ----- Method: TextDomainManager classSide>>unregisterDomain: (in category 'accessing') -----
- unregisterDomain: domainName
- 	DomainInfos removeKey: domainName.
- 	self refresh.
- 	NaturalLanguageTranslator domainUnregistered: domainName.
- !

Item was removed:
- ----- Method: TextDomainInfo>>categories (in category 'accessing') -----
- categories
- 	^categories!

Item was removed:
- ----- Method: TextDomainInfo>>matchedPackages (in category 'accessing') -----
- matchedPackages
- "Returns all the packages with this domain"
- ^PackageInfo allPackages select: [:package | self includesPackage: package name]!

Item was removed:
- ----- Method: TextDomainManager classSide>>registerPackage:domain: (in category 'accessing') -----
- registerPackage: aPackageName domain: aDomainName
- 	| domInfo |
- 	domInfo _ self domainInfoFor: aDomainName.
- 	domInfo packages add: aPackageName asSymbol.
- 	"self refresh."
- 	Packages at: aPackageName put: aDomainName
- !

Item was removed:
- ----- Method: TextDomainManager classSide>>refresh (in category 'private') -----
- refresh
- 	Packages := Dictionary new.
- 	DomainInfos keysAndValuesDo: [:domainName :domainInfo |
- 		domainInfo matchedPackages do: [:package |
- 			Packages at: package name ifPresent: [:err| self error: 'Package ', (package name asString) , '  belongs to multiple domains'].
- 			Packages at: package name put: domainName.
- 			]
- 		]
- !

Item was removed:
- ----- Method: TextDomainManager classSide>>domainInfoFor: (in category 'private') -----
- domainInfoFor: domainName
- 	^DomainInfos at: domainName ifAbsentPut: [ self registerDomain: domainName]!

Item was removed:
- ----- Method: TextDomainManager classSide>>domainInfos (in category 'private') -----
- domainInfos
- 	^DomainInfos!

Item was removed:
- ----- Method: TextDomainManager classSide>>domainForClass: (in category 'accessing') -----
- domainForClass: aClass
- 	^Classes at: aClass theNonMetaClass name ifAbsent: [self defaultDomain]!

Item was removed:
- ----- Method: TextDomainInfo>>packages (in category 'accessing') -----
- packages
- 	^packages!

Item was removed:
- Object subclass: #TextDomainInfo
- 	instanceVariableNames: 'categoryPrefixes categories packages'
- 	classVariableNames: ''
- 	poolDictionaries: ''
- 	category: 'System-Localization'!
- 
- !TextDomainInfo commentStamp: '<historical>' prior: 0!
- I hold criteria for deciding wheter a systemCategory belongs to domain. 
- - categoryPrefixes is collection of prefix of class category.
- - categories is for specifying fine grained criterion.
- !

Item was removed:
- ----- Method: TextDomainInfo>>includesPackage: (in category 'accessing') -----
- includesPackage: packageName
- 	^packages includes: packageName!

Item was removed:
- ----- Method: TextDomainInfo>>initialize (in category 'initialize-release') -----
- initialize
- 	categoryPrefixes _ Set new.
- 	categories _ IdentitySet new.
- 	packages := Set new. !

Item was removed:
- ----- Method: TextDomainManager classSide>>registerDomain: (in category 'accessing') -----
- registerDomain: domainName
- 	| domInfo |
- 	domInfo _ TextDomainInfo new.
- 	DomainInfos at: domainName put: domInfo.
- 	NaturalLanguageTranslator domainRegistered: domainName.
- 	^domInfo!

Item was removed:
- ----- Method: TextDomainInfo>>categoryPrefixes (in category 'accessing') -----
- categoryPrefixes
- 	^categoryPrefixes!

Item was removed:
- ----- Method: TextDomainManager classSide>>domainForPackageNamed: (in category 'accessing') -----
- domainForPackageNamed: packageName
- 	^Packages at: packageName ifAbsent: [self defaultDomain]!



More information about the etoys-dev mailing list