xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/examples/hello-smalltalk/hello.st.in (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
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
11PackageLoader fileInPackage: 'I18N' !
12
13In the meantime, we use this workaround."
14
15| saved sink |
16saved := Transcript message.
17sink := WriteStream with: String new.
18Transcript message: sink -> #nextPutAll:.
19PackageLoader fileInPackage: 'I18N'.
20Transcript message: saved.
21!
22
23Object subclass: #Main
24  instanceVariableNames: ''
25  classVariableNames: 'NLS'
26  poolDictionaries: ''
27  category: 'Program'
28!
29!Main methodsFor: 'running'!
30run
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
40SystemDictionary defineCFunc: 'getpid'
41  withSelectorArgs: 'getpid'
42  returning: #int
43  args: #()
44!
45
46So let's define it through an external process."
47
48!Main methodsFor: 'auxiliary stuff'!
49getpid
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
59Main new run!
60