'From Squeak3.1alpha of 28 February 2001 [latest update: #4119] on 4 June 2001 at 2:56:26 pm'! "Change Set: TranslateVocab-tk Date: 4 June 2001 Author: Ted Kaehler 1) fixed menu items in 'choose language' in the shift menu of a text pane. 2) Vocabulary>>strings returns the parts of the vocabulary for scripting that need to be translated to add a new foreign language. A template for making a new addGermanVocabulary method. 3) Instructions on how to submit a vocabulary to a web language translation site. Not very good results, but fun."! !Vocabulary commentStamp: 'tk 6/4/2001 14:52' prior: 0! Vocabulary vocabularyName a Symbol -- the formal name by which this vocabulary is known. categories a list of ElementCategory objects: the categories that comprise the vocabulary methodInterfaces an IdentityDictionary; keys are method selectors, values are MethodInterfaces A Vocabulary can be either be *abstract*, i.e. associated with a *class*, or it can be *bound to an instance*. The form that is bound to an instance is still in its infancy however. object in the *bound* form, an actual object is associated with the vocabulary limitClass in the *bound* form, an actual limit class is assocaited with the vocabulary AllMethodInterfaces This class variable is available to hold on to all method interfaces defined in the system, regardless of class. Not deployed in the first version of this code to be circulated externally. AllVocabularies A dictionary associating symbols with actual abstract vocabulary instances ------ Hints on making a vocabulary for a new foreign language. You need build a method like #addGermanVocabulary. Execute Transcript show: Vocabulary eToyVocabulary strings. and copy the text from the transcript to the method you are building. A cheap trick to get started is to use a web site that translates. Here is how. For an entry like: (clearTurtleTrails 'clear pen trails' 'Clear all the pen trails in the interior.') substitute exclamation points for single quotes by using Alt-shift-j. Most of the statements are imperatives. (clearOwnersPenTrails !!clear all pen trails!! !!clear all pen trails in my containing play field!!) This translates to (ClearOwnersPenTrails!! reinigt allen Kugelschreiber verfolgt!! !! Reinigt allen Kugelschreiber Pfade in meinem enthaltenden Spiel Feld sind!!) Which is laughable, and will certainly stimulate the author to improve it. ------! !Vocabulary methodsFor: 'initialization' stamp: 'tk 6/4/2001 14:32'! strings | strm | "Get started making a vocabulary for a foreign language. That is, build a method like #addGermanVocabulary, but for another language. Returns this vocabulary in the same form used as the input used for foreign languages. To avoid string quote problems, execute Transcript show: Vocabulary eToyVocabulary strings. and copy the text from the transcript to the method you are building." "selector elementWording documentation" strm _ WriteStream on: (String new: 400). methodInterfaces keys asSortedCollection do: [:sel | strm cr; nextPut: $(; nextPutAll: sel; tab; tab; tab; nextPut: $'; nextPutAll: (methodInterfaces at: sel) elementWording; nextPut: $'; tab; tab; tab; nextPut: $'; nextPutAll: (methodInterfaces at: sel) documentation; nextPut: $'; nextPut: $)]. ^ strm contents! ! !WordNet class methodsFor: 'as yet unclassified' stamp: 'tk 6/4/2001 13:25'! languagePrefs "Set preference of which natural language is primary. Look up definitions in it, and correct speaLanguageing in it. Also, let user set languages to translate from and to." | ch aLanguage | self canTranslateFrom. "sets defaults" ch _ PopUpMenu withCaption: 'Choose the natural language to use for:' chooseFrom: 'word definition and spelling verification (', (Preferences parameterAt: #myLanguage default: [#English]) asString ,')...\', 'language to translate FROM (now ', (Preferences parameterAt: #languageTranslateFrom default: [#English]) asString ,')...\', 'language to translate TO (now ', (Preferences parameterAt: #languageTranslateTo default: [#German]) asString ,')...\'. ch = 1 ifTrue: [ aLanguage _ PopUpMenu withCaption: 'The language for word definitions and speaLanguageing verification:' chooseFrom: Languages. aLanguage > 0 ifTrue: [^ Preferences setParameter: #myLanguage to: (Languages at: aLanguage) asSymbol]]. ch = 2 ifTrue: [aLanguage _ PopUpMenu withCaption: 'The language to translate from:' chooseFrom: CanTranslateFrom. aLanguage > 0 ifTrue: [^ Preferences setParameter: #languageTranslateFrom to: (CanTranslateFrom at: aLanguage) asSymbol]]. ch = 3 ifTrue: [aLanguage _ PopUpMenu withCaption: 'The language to translate to' chooseFrom: CanTranslateFrom. aLanguage > 0 ifTrue: [^ Preferences setParameter: #languageTranslateTo to: (CanTranslateFrom at: aLanguage) asSymbol]]. "Maybe let the user add another language if he knows the server can take it." " ch _ (PopUpMenu labelArray: Languages, {'other...'. 'Choose language to translate from...'}) startUpWithCaption: 'Choose the language of dictionary for word definitions.'. ch = 0 ifTrue: [^ Preferences setParameter: #myLanguage to: #English]. (ch <= Languages size) ifTrue: [aLanguage _ Languages at: ch]. ch = (Languages size + 1) ifTrue: [ aLanguage _ FiaLanguageInTheBlank request: 'Name of the primary language']. aLanguage ifNotNil: [^ Preferences setParameter: #myLanguage to: aLanguage asSymbol]. "! ! EToyVocabulary removeSelector: #strings!