'From etoys2.2 of 21 September 2007 [latest update: #1667] on 27 September 2007 at 1:21:44 am'! "Change Set: stringTransl-bf Date: 26 September 2007 Author: Bert Freudenberg Make TextMorphs translateable. To try, simply switch a project's language, edit the text, and switch back."! !LocaleID class methodsFor: 'accessing' stamp: 'bf 9/26/2007 16:24'! previous ^Locale previous localeID! ! !Project methodsFor: 'language' stamp: 'bf 9/26/2007 16:18'! updateLocaleDependentsWithPreviousSupplies: aCollection gently: gentlyFlag "Set the project's natural language as indicated" | morphs | morphs := IdentitySet new: 400. ActiveWorld allMorphsAndBookPagesInto: morphs. morphs do: [:morph | morph isTileScriptingElement ifTrue: [morph localeChanged]. morph class == TextMorph ifTrue: [morph localeChanged]]. Flaps disableGlobalFlaps: false. Preferences sugarNavigator ifTrue: [Flaps addAndEnableEToyFlapsWithPreviousEntries: aCollection. ActiveWorld addGlobalFlaps] ifFalse: [Preferences eToyFriendly ifTrue: [Flaps addAndEnableEToyFlaps. ActiveWorld addGlobalFlaps] ifFalse: [Flaps enableGlobalFlaps]]. (Project current isFlapIDEnabled: 'Navigator' translated) ifFalse: [Flaps enableDisableGlobalFlapWithID: 'Navigator' translated]. ParagraphEditor initializeTextEditorMenus. MenuIcons initializeTranslations. gentlyFlag ifTrue: [ LanguageEnvironment localeChangedGently. ] ifFalse: [ LanguageEnvironment localeChanged. ]. #(PartsBin ParagraphEditor BitEditor FormEditor StandardSystemController) do: [ :key | Smalltalk at: key ifPresent: [ :class | class initialize ]]. ActiveWorld reformulateUpdatingMenus. "self setFlaps. self setPaletteFor: aLanguageSymbol." ! ! !TextMorph methodsFor: 'localization' stamp: 'bf 9/27/2007 01:04'! addTranslationItemsTo: aMenu | submenu | (self hasProperty: #translations) ifFalse: [^self]. submenu := MenuMorph new defaultTarget: self. self translations keysAndValuesDo: [:localeID :translation | submenu add: localeID asString, ': ', (translation asString contractTo: 30) selector: #setLocale: argument: localeID]. aMenu add: 'translations...' translated subMenu: submenu! ! !TextMorph methodsFor: 'localization' stamp: 'bf 9/27/2007 01:13'! localeChanged "Remember contents for previous locale and change contents to new locale if existing. Sent from Project>>updateLocaleDependents" | locale oldContents | locale := self valueOfProperty: #locale ifAbsent: [#none]. oldContents := self translations at: locale ifAbsent: [nil]. oldContents = self contents ifFalse: [ self translations at: LocaleID previous put: self contents copy. self setProperty: #locale toValue: LocaleID previous]. self setLocale: LocaleID current! ! !TextMorph methodsFor: 'localization' stamp: 'bf 9/27/2007 01:14'! setLocale: aLocaleID "If there is a translation for aLoacalId, switch to it" self translations at: aLocaleID ifPresent: [:translation| self newContents: translation. self setProperty: #locale toValue: aLocaleID]. ! ! !TextMorph methodsFor: 'localization' stamp: 'bf 9/27/2007 01:04'! translations ^self valueOfProperty: #translations ifAbsentPut: [Dictionary new]! ! !TextMorph methodsFor: '*connectorsshapes-menu' stamp: 'bf 9/27/2007 00:16'! addCustomMenuItems: aCustomMenu hand: aHandMorph | outer | super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'text properties...' translated action: #changeTextColor. aCustomMenu addUpdating: #autoFitString target: self action: #autoFitOnOff. aCustomMenu addUpdating: #wrapString target: self action: #wrapOnOff. aCustomMenu add: 'text margins...' translated action: #changeMargins:. aCustomMenu add: 'add predecessor' translated action: #addPredecessor:. aCustomMenu add: 'add successor' translated action: #addSuccessor:. self addTranslationItemsTo: aCustomMenu. (Preferences noviceMode or: [Preferences simpleMenus]) ifFalse: [aCustomMenu add: 'code pane menu...' translated action: #yellowButtonActivity. aCustomMenu add: 'code pane shift menu...' translated action: #shiftedYellowButtonActivity]. outer _ self owner. outer ifNotNil: [ outer isLineMorph ifTrue: [container isNil ifTrue: [aCustomMenu add: 'follow owner''s curve' translated action: #followCurve] ifFalse: [aCustomMenu add: 'reverse direction' translated action: #reverseCurveDirection. aCustomMenu add: 'set baseline' translated action: #setCurveBaseline:]] ifFalse: [self fillsOwner ifFalse: [aCustomMenu add: 'fill owner''s shape' translated action: #fillingOnOff] ifTrue: [aCustomMenu add: 'rectangular bounds' translated action: #fillingOnOff]. self avoidsOcclusions ifFalse: [aCustomMenu add: 'avoid occlusions' translated action: #occlusionsOnOff] ifTrue: [aCustomMenu add: 'ignore occlusions' translated action: #occlusionsOnOff]]]. aCustomMenu addLine. aCustomMenu add: 'holder for characters' translated action: #holderForCharacters ! !