Install gettext-0.18.1.1.tar.gz
[msysgit.git] / mingw / share / doc / gettext / examples / hello-smalltalk / hello.st.in
blob4ddccad8bb11187e39942afd087c86e8e1d99ab0
1 " Example for use of GNU gettext.
2 This file is in the public domain.
4 Source code of the GNU Smalltalk program.
7 "Unfortunately the PackageLoader method fileInPackage: is extra verbose:
8 It outputs 'Loading package I18N'. This will be fixed in smalltalk-2.2.
10 PackageLoader fileInPackage: 'I18N' !
12 In the meantime, we use this workaround."
14 | saved sink |
15 saved := Transcript message.
16 sink := WriteStream with: String new.
17 Transcript message: sink -> #nextPutAll:.
18 PackageLoader fileInPackage: 'I18N'.
19 Transcript message: saved.
22 Object subclass: #Main
23 instanceVariableNames: ''
24 classVariableNames: 'NLS'
25 poolDictionaries: ''
26 category: 'Program'
28 !Main methodsFor: 'running'!
29 run
30 NLS := I18N Locale default messages domain: 'hello-smalltalk' localeDirectory: '@localedir@'.
31 Transcript showCr: (NLS ? 'Hello, world!').
32 Transcript showCr: ((NLS ? 'This program is running as process number %1.') bindWith: self getpid).
36 "Unfortunately I cannot define getpid like this - it gives
37 'C function getpid not defined'.
39 SystemDictionary defineCFunc: 'getpid'
40 withSelectorArgs: 'getpid'
41 returning: #int
42 args: #()
45 So let's define it through an external process."
47 !Main methodsFor: 'auxiliary stuff'!
48 getpid
49 | stream pid |
50 stream := FileDescriptor popen: 'echo $PPID' dir: #read.
51 pid := stream contents asNumber.
52 stream close.
53 ^ pid
58 Main new run!