1 " Example for use of GNU gettext. 2 Copyright (C) 2003 Free Software Foundation, Inc. 3 This file is in the public domain. 4 5 Source code of the GNU Smalltalk program. 6 " 7 8 "Unfortunately the PackageLoader method fileInPackage: is extra verbose: 9 It outputs 'Loading package I18N'. This will be fixed in smalltalk-2.2. 10 11 PackageLoader fileInPackage: 'I18N' ! 12 13 In the meantime, we use this workaround." 14 15 | saved sink | 16 saved := Transcript message. 17 sink := WriteStream with: String new. 18 Transcript message: sink -> #nextPutAll:. 19 PackageLoader fileInPackage: 'I18N'. 20 Transcript message: saved. 21 ! 22 23 Object subclass: #Main 24 instanceVariableNames: '' 25 classVariableNames: 'NLS' 26 poolDictionaries: '' 27 category: 'Program' 28 ! 29 !Main methodsFor: 'running'! 30 run 31 NLS := I18N Locale default messages domain: 'hello-smalltalk' localeDirectory: '@localedir@'. 32 Transcript showCr: (NLS ? 'Hello, world!'). 33 Transcript showCr: ((NLS ? 'This program is running as process number %1.') bindWith: self getpid). 34 ! 35 36 37 "Unfortunately I cannot define getpid like this - it gives 38 'C function getpid not defined'. 39 40 SystemDictionary defineCFunc: 'getpid' 41 withSelectorArgs: 'getpid' 42 returning: #int 43 args: #() 44 ! 45 46 So let's define it through an external process." 47 48 !Main methodsFor: 'auxiliary stuff'! 49 getpid 50 | stream pid | 51 stream := FileDescriptor popen: 'echo $PPID' dir: #read. 52 pid := stream contents asNumber. 53 stream close. 54 ^ pid 55 ! 56 ! 57 58 59 Main new run! 60