[Seaside-dev] Seaside-Gettext
Johan Brichau
johan at inceptive.be
Sat May 21 13:44:56 UTC 2011
Hi,
I am using Seaside-GetText and noticed that the 'pot' template exporter was not picking up the strings to which #seasideTranslated is sent.
This message is handy for translating attributes, while the #translate: message is targeting the inner text of a markup node. For example:
html jQuery this editable
...
submit: 'ok' seasideTranslated;
cancel: 'cancel' seasideTranslated;
...
So, I went ahead and added support to the appropriate method (see code below). Is there any change of seeing this in the distributed package?
And if I can help to do that, let me know.
cheers,
Johan
----
translatedArguments
"self new translatedArguments"
| searcher currentClass result innerMatchHandler matchHandler1 matchHandler2 |
currentClass := WAValueHolder with: nil.
result := GROrderedMultiMap new.
innerMatchHandler := [ :node :literal |
| key |
key := MethodReference
class: currentClass contents
selector: node methodNode selector.
result at: key add: literal value ].
matchHandler1 := [ :node :answer |
| firstArgument |
firstArgument := node arguments first.
firstArgument isLiteral ifTrue: [innerMatchHandler value: node value: firstArgument]].
matchHandler2 := [ :node :answer |
node receiver isLiteral ifTrue: [innerMatchHandler value: node value: node receiver]].
searcher := RBParseTreeSearcher new
matches: '`@object translate: `#string' do: matchHandler1;
matches: '`@object translate: `#string to: `@arg' do: matchHandler1;
matches: '`#string seasideTranslated' do: matchHandler2;
matches: '`#string seasideTranslatedTo: `@arg' do: matchHandler2;
yourself.
BrowserEnvironment new classesAndSelectorsDo: [ :class :selector |
(searcher canMatchMethod: class >> selector) ifTrue: [
| tree |
(tree := class parseTreeFor: selector) notNil ifTrue: [
currentClass contents: class.
searcher executeTree: tree ] ] ].
^ Array streamContents: [ :stream |
result keysDo: [ :key |
stream nextPut: key -> (result allAt: key) ] ]
More information about the seaside-dev
mailing list