• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/timemachine/gettext-0.17/gettext-tools/examples/hello-smalltalk/
1" Example for use of GNU gettext.
2  This file is in the public domain.
3
4  Source code of the GNU Smalltalk program.
5"
6
7"Unfortunately the PackageLoader method fileInPackage: is extra verbose:
8 It outputs 'Loading package I18N'. This will be fixed in smalltalk-2.2.
9
10PackageLoader fileInPackage: 'I18N' !
11
12In the meantime, we use this workaround."
13
14| saved sink |
15saved := Transcript message.
16sink := WriteStream with: String new.
17Transcript message: sink -> #nextPutAll:.
18PackageLoader fileInPackage: 'I18N'.
19Transcript message: saved.
20!
21
22Object subclass: #Main
23  instanceVariableNames: ''
24  classVariableNames: 'NLS' 
25  poolDictionaries: ''
26  category: 'Program'
27!
28!Main methodsFor: 'running'!
29run
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).
33!
34
35
36"Unfortunately I cannot define getpid like this - it gives
37 'C function getpid not defined'.
38
39SystemDictionary defineCFunc: 'getpid'
40  withSelectorArgs: 'getpid'
41  returning: #int
42  args: #()
43!
44
45So let's define it through an external process."
46
47!Main methodsFor: 'auxiliary stuff'!
48getpid
49  | stream pid |
50  stream := FileDescriptor popen: 'echo $PPID' dir: #read.
51  pid := stream contents asNumber.
52  stream close.
53  ^ pid
54!
55!
56
57
58Main new run!
59