Nicolas Cellier uploaded a new version of GetText to project The Inbox:
http://source.squeak.org/inbox/GetText-nice.19.mcz ==================== Summary ==================== Name: GetText-nice.19 Author: nice Time: 24 March 2012, 6:27:42.313 pm UUID: c676d287-d02a-4430-878b-a35508793073 Ancestors: GetText-edc.18 Remove Undeclared references. Note1: This implies moving an inst. var. declaration in an upper class, no idea how MC can handle this, cross fingers... Note2: Since some of these methods were in startup: I don't believe the code was ever functional in Squeak, and I did not even try. For these two reasons, I post in inbox, not directly in trunk =============== Diff against GetText-edc.18 =============== Item was changed: ----- 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 exportTranslationsFor: aLanguage. + self exportUntranslatedFor: aLanguage] - self exportTranslations. - self exportUntranslated] ensure: [stream close]! 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 added: + ----- Method: GetTextExporter>>exportTranslationsFor: (in category 'private-translations') ----- + exportTranslationsFor: aLanguage + | keys size | + keys := aLanguage 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: (aLanguage translations + at: (keys at: index)). + bar value: index / size]]! 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 added: + ----- Method: GetTextExporter>>exportUntranslatedFor: (in category 'private-translations') ----- + exportUntranslatedFor: aLanguage + | keys | + keys := aLanguage 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 changed: NaturalLanguageTranslator subclass: #InternalTranslator + instanceVariableNames: '' - instanceVariableNames: 'generics' classVariableNames: 'AllKnownPhrases CachedTranslations' poolDictionaries: '' category: 'GetText-Localization'! !InternalTranslator commentStamp: 'tak 10/19/2007 11:12' prior: 0! An InternalTranslator is used a translation dictionary in a image. You can use it without any external translation file. Structure: generics Dictionary -- msgid -> msgstr ! Item was changed: ----- Method: Locale class>>switchAndInstallFontToID:gently: (in category 'accessing') ----- switchAndInstallFontToID: localeID gently: gentlyFlag - | locale result env envFound ret fontInImage menu | - "Assumption: Rainbow => can try Pango" "Logic: - - in Sugar, we don't bother asking any questions, and we don't bother automatically loading fonts. - in Sugar, and if the font is available, use the font. - in Sugar, and if the font is not in the image, try to enable Pango. - - if the previous step fails, notify the user that you cannot switch to the language. - not in Rainbow, - if the font is in the image, use the font. - if the font is not in the image, - ask to choose: - load font - try to enable pango, if pango is available - or cancel. - if the previous step fails, notify the user that you cannot switch to the language. Details: - how to check non-pango font is available: - if the language environment for the locale doesn't exist, the font is not available. - if font loading fails, it is not available. - how to check if the language environment doesn't exist: - if the locales languageEnvironment is Latin1 but the locale isn't it is not available. " locale := Locale localeID: localeID. env := locale languageEnvironment. result := true. envFound := (Latin1Environment supportedLanguages includes: locale isoLanguage) or: [(env isMemberOf: Latin1Environment) not]. fontInImage := envFound and: [env isFontAvailable]. + fontInImage ifFalse: [ + menu := MenuMorph new. + menu defaultTarget: menu. + envFound ifTrue: [menu add: 'load font' translated selector: #modalSelection: argument: #loadFont]. + menu add: 'cancel' translated selector: #modalSelection: argument: #cancel. + menu addTitle: 'This language needs additional fonts. - SugarLauncher isRunningInSugar ifTrue: [ - fontInImage ifFalse: [ - "font is not available in the image. Even don't ask for font installation." - Cursor wait showWhile: [ - Preferences setPreference: #usePangoRenderer toValue: true. - TextMorph usePango: true]]. - ] ifFalse: [ - fontInImage ifFalse: [ - menu := MenuMorph new. - menu defaultTarget: menu. - envFound ifTrue: [menu add: 'load font' translated selector: #modalSelection: argument: #loadFont]. - RomePluginCanvas pangoIsAvailable ifTrue: [menu add: 'enable Pango' translated selector: #modalSelection: argument: #enablePango]. - menu add: 'cancel' translated selector: #modalSelection: argument: #cancel. - menu addTitle: 'This language needs additional fonts. Do you want to install the fonts?' translated. + ret := menu invokeModal. + ret = #loadFont ifTrue: [result := env installFont. result ifTrue: [StrikeFont setupDefaultFallbackTextStyle]]. + (ret ~~ #loadFont and: [ret ~~ #enablePango]) ifTrue: [result := false]]. - ret := menu invokeModal. - ret = #loadFont ifTrue: [result := env installFont. result ifTrue: [StrikeFont setupDefaultFallbackTextStyle]]. - ret = #enablePango ifTrue: [ - (result := RomePluginCanvas pangoIsAvailable) ifTrue: [ - Cursor wait showWhile: [ - Preferences setPreference: #usePangoRenderer toValue: true. - TextMorph usePango: true]]]. - (ret ~~ #loadFont and: [ret ~~ #enablePango]) ifTrue: [result := false]]]. - result ifFalse: [self inform: 'Cannot load additional fonts' translated] ifTrue: [self switchTo: locale gently: gentlyFlag]. ! Item was changed: Object subclass: #NaturalLanguageTranslator + instanceVariableNames: 'id generics' - instanceVariableNames: 'id' classVariableNames: 'Translators' poolDictionaries: '' category: 'GetText-Localization'! !NaturalLanguageTranslator commentStamp: '<historical>' prior: 0! abstract class of natural language translator. Class side manages and holds loaded instances of concrete classes.! Item was added: + ----- Method: NaturalLanguageTranslator class>>allKnownPhrases (in category 'private') ----- + allKnownPhrases + ^AllKnownPhrases ifNil: [AllKnownPhrases := Dictionary new: 2051]! Item was added: + ----- Method: NaturalLanguageTranslator class>>cachedTranslations (in category 'private') ----- + cachedTranslations + "CachedTranslations := nil" + ^CachedTranslations ifNil: [CachedTranslations := Dictionary new]! Item was added: + ----- Method: NaturalLanguageTranslator class>>cleanUp (in category 'class initialization') ----- + cleanUp + "Flush caches" + + CachedTranslations := nil. + AllKnownPhrases := nil.! Item was changed: ----- Method: NaturalLanguageTranslator>>fileOutOn:keys: (in category 'fileIn/fileOut') ----- fileOutOn: aStream keys: keys "self current fileOutOn: Transcript. Transcript endEntry" (keys + ifNil: [self generics keys asArray sort]) - ifNil: [generics keys asArray sort]) do: [:key | self + nextChunkPut: (self generics associationAt: key) - nextChunkPut: (generics associationAt: key) on: aStream]. keys ifNil: [self untranslated do: [:each | self nextChunkPut: each -> '' on: aStream]]. aStream nextPut: $!!; cr! |
Free forum by Nabble | Edit this page |