'From Squeak3.8-Nihongo of 14 March 2005 [latest update: #27] on 14 March 2005 at 3:57:02 pm'! "Change Set: mimeTranslation Date: 25 February 2005 Author: Yoshiki Ohshima Add the feature to handle MIME encoded, Gzipped translation file. -- Fix in order to load in other locale. --tak "! !NaturalLanguageTranslator methodsFor: 'fileIn/fileOut' stamp: 'yo 2/25/2005 09:37'! writeAsMimeString | fileName fileStream tmpStream s2 gzs | tmpStream _ MultiByteBinaryOrTextStream on: ''. tmpStream converter: UTF8TextConverter new. self fileOutOn: tmpStream. s2 _ RWBinaryOrTextStream on: ''. gzs := GZipWriteStream on: s2. tmpStream reset. gzs nextPutAll: (tmpStream binary contentsOfEntireFile asString) contents. gzs close. s2 reset. fileName _ id isoString, '.translation.gz.mime'. fileStream _ FileStream newFileNamed: fileName. fileStream nextPutAll: (Base64MimeConverter mimeEncode: s2) contents. fileStream close. ! ! !NaturalLanguageTranslator class methodsFor: 'file-services' stamp: 'tak 3/14/2005 15:51'! loadForLocaleIsoString: localeString fromGzippedMimeLiteral: mimeString "merge the translation from the mime literal." | stream localeID translator gs rbStream s currentPlatform | s := Base64MimeConverter mimeDecodeToBytes: mimeString readStream. s reset. gs := GZipReadStream on: s. rbStream := MultiByteBinaryOrTextStream with: gs contents asString. rbStream converter: UTF8TextConverter new. rbStream reset. localeID := LocaleID isoString: localeString. currentPlatform := Locale currentPlatform. [Locale currentPlatform: (Locale localeID: localeID). stream := ReadStream on: rbStream contents] ensure: [Locale currentPlatform: currentPlatform]. translator := self localeID: localeID. translator loadFromStream: stream. LanguageEnvironment resetKnownEnvironments! !