Re: AW: i18n Object without need for translation
Peter Zechmeister <[email protected]>
| Newsgroups | gmane.comp.cms.zms.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
thanx for the hint, but I am afraid, it isn't as simple as it sounds.
Here is the code, which worked for me after all:
This Script is implemented as an DTML-Method attribute of an custom
object with the id "test". The id of the script is
"onChangeObjEvt_test".
1)<dtml-with context>
2)<dtml-if "meta_id =='test'">
<dtml-let currentLang="REQUEST.lang"
3) change_dt="getObjProperty('change_dt', REQUEST)"
4) change_uid="getObjProperty('change_uid', REQUEST)" >
<dtml-in "getLanguages()" prefix="loop">
<dtml-call "REQUEST.set('lang', loop_item)">
<dtml-call "setObjProperty('change_dt', change_dt, lang=loop_item)">
<dtml-call "setObjProperty('change_uid', change_uid,
lang=loop_item)">
</dtml-in>
<dtml-call "REQUEST.set('lang', currentLang)">
</dtml-let>
</dtml-if>
</dtml-with>
There some awkward things in this matter:
The Id of the Method-Attribute _must not_ be "onChangeObjEvt". You will
run into complications when you implement further objects with
attributes of the same name.
Name it "onChangeObjEvt_test" for example, to make it distinguishable.
Its name must just start with "onChangeObjEvt".
Now for the script:
1) This is dtml-unusual but necessary. You would not have any namespace
else.
2) Test, if we are in the right object type. Forget this, and your
script will allways do things when saving any object of any type. In my
case every new item got "translated" automatically (Textareas,
Folders, ...). ZMS runs every script in your system which name starts
with "onChangeObjEvt" on every pressed "Save" button. Theses scripts
have to make sure by themselves if they are really meant.
3) 4) As I found out, these two properties must be set in a secondary
language, to make a object "translated". Active-Flag is not needed.
The rest is self explaining, I think.
I dunno, why this feature is implemented in this way. But I think it
would be worth to simplify this in future ZMS versions.
Regards
PeterZ
Am Mittwoch, den 01.07.2009, 10:59 +0200 schrieb Dr. Frank Hoffmann:
>
>
> Hi,
> Please, add an attribute method "onChangeObjEvt()", which iterates on
> object
> changes through all languages, via getLanguages(), und sets the
> "active"-Property:
> <dtml-call "setObjProperty('active',True)">
>
> Best regdards
> fh, moderator
>
>
>
>
>
--
"Ordnung ist für einfach denkende Menschen das Ergebnis der ordnenden
Tätigkeit eines ordnenden Wesens.", Hayek