'From etoys3.0 of 24 February 2008 [latest update: #2100] on 27 August 2008 at 6:05:50 pm'! "Change Set: pangoPrefAug27-yo Date: 27 August 2008 Author: Yoshiki Ohshima Avoid to attempt font autoload under Sugar/Rainbow. Enable Pango when needed."! !LanguageEnvironment class methodsFor: 'private' stamp: 'yo 8/27/2008 15:56'! usePangoRenderer | tr font phraseTest fontName | Preferences usePangoRenderer ifTrue: [^ true]. "first, see if people specified font." tr := NaturalLanguageTranslator current. fontName := tr translate: 'Linux-Font'. (fontName ~= 'Linux-Font' and: [(StrikeFont familyNames includes: fontName asSymbol) not]) ifTrue: [^ true]. font := TextStyle defaultFont. phraseTest := [:phrase | phrase do: [:c | (font hasGlyphWithFallbackOf: c) ifFalse: [^ true]]]. "Hopefully people start translating phrases that are really used, but also people translate on the Pootle server which has a ideosyncratic ordering..." #('Rectangle' 'Text' 'forward by' 'turn by' 'color' 'choose new graphic' 'linear gradient' 'open as Flash' 'set custom action' 'show compressed size' 'more smoothing') do: [:ph | phraseTest value: (tr translate: ph)]. "But it is not often the case; so a bit more testing..." 10 timesRepeat: [ phraseTest value: tr atRandom]. ^ false. ! ! !Locale class methodsFor: 'accessing' stamp: 'yo 8/27/2008 18:02'! switchAndInstallFontToID: localeID gently: gentlyFlag | locale | locale := Locale localeID: localeID. SugarLauncher isRunningInRainbow ifFalse: [ locale languageEnvironment isFontAvailable ifFalse: [(self confirm: 'This language needs additional fonts. Do you want to install the fonts?' translated) ifTrue: [locale languageEnvironment installFont. StrikeFont setupDefaultFallbackTextStyle] ifFalse: [ self]]]. self switchTo: locale gently: gentlyFlag ! ! !MOFile methodsFor: 'public' stamp: 'yo 8/27/2008 13:09'! atRandom ^ self translatedString:nStrings atRandom. ! ! !MOFile methodsFor: 'public' stamp: 'yo 8/27/2008 11:31'! translationFor: aString aString size = 0 ifTrue: [^ '']. "Gettext header" ^ (self searchByDictionary: aString) ifNil: [aString] ! ! !NaturalLanguageTranslator methodsFor: 'accessing' stamp: 'yo 8/27/2008 13:10'! atRandom self subclassResponsibility. ! ! !GetTextTranslator methodsFor: 'accessing' stamp: 'yo 8/27/2008 13:09'! atRandom ^ (moFiles atRandom value) atRandom! ! !InternalTranslator methodsFor: 'accessing' stamp: 'yo 8/27/2008 12:54'! atRandom ^ generics atRandom value. ! ! !StrikeFont methodsFor: 'accessing' stamp: 'yo 8/27/2008 12:10'! hasGlyphWithFallbackOf: aCharacter (self hasGlyphOf: aCharacter) ifTrue: [^ true]. ^ fallbackFont ifNotNil: [fallbackFont hasGlyphWithFallbackOf: aCharacter] ifNil: [false]. ! ! !StrikeFontSet methodsFor: 'accessing' stamp: 'yo 8/27/2008 12:25'! hasGlyphWithFallbackOf: aCharacter | index f | index _ aCharacter leadingChar +1. fontArray size < index ifTrue: [^ false]. (f _ fontArray at: index) ifNil: [^ false]. ^ f hasGlyphWithFallbackOf: aCharacter. ! ! !TTCFont methodsFor: 'accessing' stamp: 'yo 8/27/2008 12:10'! hasGlyphWithFallbackOf: aCharacter (self hasGlyphOf: aCharacter) ifTrue: [^ true]. ^ fallbackFont ifNotNil: [fallbackFont hasGlyphWithFallbackOf: aCharacter] ifNil: [false]. ! ! !TTCFontSet methodsFor: 'accessing' stamp: 'yo 8/27/2008 12:21'! hasGlyphWithFallbackOf: aCharacter | index f | index _ aCharacter leadingChar +1. fontArray size < index ifTrue: [^ false]. (f _ fontArray at: index) ifNil: [^ false]. ^ f hasGlyphWithFallbackOf: aCharacter. ! ! NepaleseEnvironment class removeSelector: #usePangoRenderer!