[squeak-dev] The Trunk: GetText-nice.23.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Mar 31 13:01:49 UTC 2012
Nicolas Cellier uploaded a new version of GetText to project The Trunk:
http://source.squeak.org/trunk/GetText-nice.23.mcz
==================== Summary ====================
Name: GetText-nice.23
Author: nice
Time: 31 March 2012, 3:01:23.958 pm
UUID: 45328fae-3176-4dab-b10f-f008856d3d8b
Ancestors: GetText-edc.22
Remove 2 underscore assignment.
They were not detected automatically because not separated by space.
Apply this minimal formatting rule : indent the method body.
Whithout this, reading code really hurts my feeling.
=============== Diff against GetText-edc.22 ===============
Item was changed:
----- 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.
- 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 changed:
----- 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.
- 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 changed:
----- 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.
- 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 changed:
----- Method: TextDomainManager class>>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 , {'Etoys-Tiles'}!
- "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 , {'Etoys-Tiles'}!
Item was changed:
----- Method: TextDomainManager class>>allMethodsWithTranslations (in category 'accessing') -----
allMethodsWithTranslations
+ "Look for #translated calls"
+ | methodsWithTranslations |
+ methodsWithTranslations := TranslatedReceiverFinder new stringReceiversWithContext: #translated.
+ methodsWithTranslations := methodsWithTranslations ,
+ (TranslatedReceiverFinder new stringReceiversWithContext: #translatedNoop).
- "Look for #translated calls"
- | methodsWithTranslations |
- methodsWithTranslations := TranslatedReceiverFinder new stringReceiversWithContext: #translated.
- methodsWithTranslations := methodsWithTranslations, (TranslatedReceiverFinder new
- stringReceiversWithContext: #translatedNoop).
+ methodsWithTranslations := methodsWithTranslations collect: [:each | each key compiledMethod].
- 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]).
- "Look for Etoys tiles and vocabularies"
- methodsWithTranslations := methodsWithTranslations, (EToyVocabulary allPhrasesWithContextToTranslate collect: [:r |
- (MethodReference new setStandardClass: r second methodSymbol: r third) compiledMethod.
- ]).
+ ^methodsWithTranslations!
- ^methodsWithTranslations!
Item was changed:
----- Method: TextDomainManager class>>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?"
- "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 changed:
----- Method: TextDomainManager class>>domainForClass: (in category 'accessing') -----
domainForClass: aClass
+ ^'etoys'!
- ^'etoys'!
Item was changed:
----- Method: TextDomainManager class>>domainForPackage: (in category 'accessing') -----
domainForPackage: aPackageInfo
+ "Package names and text domains are synonyms now"
- "Package names and text domains are synonyms now"
^aPackageInfo name!
Item was changed:
----- Method: TextDomainManager class>>textDomainProperty (in category 'private') -----
textDomainProperty
+ ^#textDomain!
- ^#textDomain!
Item was changed:
----- Method: TextDomainManager class>>updateDomainOfAllMethodsWithTranslations (in category 'private') -----
updateDomainOfAllMethodsWithTranslations
+ self allMethodsWithTranslations do: [:each |
+ self updateDomainOfMethod: each]!
- self allMethodsWithTranslations do: [:each|
- self updateDomainOfMethod: each
- ]!
More information about the Squeak-dev
mailing list
|