--- a/ResourcePack.st Thu Apr 19 17:37:14 2001 +0200
+++ b/ResourcePack.st Fri Apr 20 12:32:03 2001 +0200
@@ -50,31 +50,31 @@
where 'className' is built by the usual abbreviation mechanism (see abbrev-files).
Conditional mappings are possible, by including lines as:
- #if <expression>
- #endif
+ #if <expression>
+ #endif
in the resourcefile. Example:
file 'foo.rs':
- #if Language == #german
- 'abort' 'Abbruch'
- #endif
- #if Language == #french
- 'abort' 'canceller'
- #endif
+ #if Language == #de
+ 'abort' 'Abbruch'
+ #endif
+ #if Language == #fr
+ 'abort' 'canceller'
+ #endif
the corresponding resource-strings are accessed (from methods within the class)
using:
- resources string:'abort'
+ resources string:'abort'
returning the mapped string (i.e. 'Abbruch' if the global Language is set
- to #german)..
+ to #de)..
If no corresponding entry is found in the resources, the key is returned;
alternatively, use:
- resources string:'foo' default:'bar'
+ resources string:'foo' default:'bar'
which returns 'bar', if no resource definition for 'foo' is found.
Translations can also include arguments, such as:
- resources string:'really delete %1' with:fileName
+ resources string:'really delete %1' with:fileName
This scheme has the advantage, that you can write your programs using your
native language strings. Later, when new languages are to be supported,
@@ -98,32 +98,32 @@
(which is better than nothing or empty button labels ;-)
Summary:
- in subclasses of View and ApplicationModel,
- instead of writing:
+ in subclasses of View and ApplicationModel,
+ instead of writing:
- ...
- b := Button label:'press me'
- ...
+ ...
+ b := Button label:'press me'
+ ...
- always write:
+ always write:
- ...
- b := Button label:(resources string:'press me')
- ...
+ ...
+ b := Button label:(resources string:'press me')
+ ...
- if your class is not a subclass of one of the above, AND you need
- resource translations, you wont inherit the resources variable
- (which is automatically initialized).
- In this case, you have to ask the ResourcePack class explicitely for
- a corresponding package:
+ if your class is not a subclass of one of the above, AND you need
+ resource translations, you wont inherit the resources variable
+ (which is automatically initialized).
+ In this case, you have to ask the ResourcePack class explicitely for
+ a corresponding package:
- ResourcePack for:aClassName
+ ResourcePack for:aClassName
- as an example, see how the Date class gets the national names of
- week & monthnames.
+ as an example, see how the Date class gets the national names of
+ week & monthnames.
[author:]
- Claus Gittinger
+ Claus Gittinger
"
!
@@ -132,43 +132,43 @@
normally, resources are found in files named after their classes sourcefile
For example, the FileBrowsers resources are found in 'FBrowser.rs'.
For the examples below, we process resources from a constant string;
- this is NOT representative.
- [exBegin]
- |stream res|
+ this is NOT representative.
+ [exBegin]
+ |stream res|
- stream := ReadStream on:'
+ stream := ReadStream on:'
foo ''the translation for foo''
-#if Language == #german
+#if Language == #de
bar ''die deutsche uebersetzung von bar''
baz ''baz hat den Wert %1''
#endif
-#if Language == #french
+#if Language == #fr
bar ''bar en francaise''
baz ''%1, c''''est baz''
#endif
'.
- res := ResourcePack new readFromResourceStream:stream in:nil.
+ res := ResourcePack new readFromResourceStream:stream in:nil.
- Transcript showCR:'baz is translated to: ' , (res string:'baz' with:'1234').
- Transcript showCR:'bar is translated to: ' , (res string:'bar').
- Transcript showCR:'foo is translated to: ' , (res string:'foo').
- Transcript showCR:'fooBar is translated to: ' , (res string:'fooBar').
- [exEnd]
+ Transcript showCR:'baz is translated to: ' , (res string:'baz' with:'1234').
+ Transcript showCR:'bar is translated to: ' , (res string:'bar').
+ Transcript showCR:'foo is translated to: ' , (res string:'foo').
+ Transcript showCR:'fooBar is translated to: ' , (res string:'fooBar').
+ [exEnd]
set the Language to french:
- [exBegin]
- Language := #french
- [exEnd]
+ [exBegin]
+ Language := #fr
+ [exEnd]
and repeat the above.
back to english:
- [exBegin]
- Language := #english
- [exEnd]
+ [exBegin]
+ Language := #en
+ [exEnd]
back to german:
- [exBegin]
- Language := #german
- [exEnd]
+ [exBegin]
+ Language := #de
+ [exEnd]
"
! !
@@ -782,6 +782,6 @@
!ResourcePack class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.66 2001-03-19 09:13:00 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.67 2001-04-20 10:32:03 stefan Exp $'
! !
ResourcePack initialize!