Hi cocooners, I first wrote in cocoon-user for features request about the I18nTransformer (mainly for markup in i:text and i:params) and were asked to make a patch. So I've done it.
I rewrote almost all off I18NTrans. except date and other formatting code. I used another implementation of XMLResourceBundle which indexes MirrorRecorders instead of Strings. MirrorRecorders basically conserve events ({start/end}Element and characters) and resend them later to a defined contentHandler. I use it to create the translated messages and parse i:text and params. I first thought XMLFragment would do the work, but i really only needed to store events. I also have an interface EventRecorder for MirrorRecorder. Just a convenience for subclasses (StartEventRecorder, ...). Substitution is applied when sending the first recorded "i:text" events. It uses the same notation as before "every{0} you {1}", but you can also insert markup inside parameters or directly in the "i:text" (useful for links). Date and numbers are allowed in params. I also added in-place translations or 'locale' tests. It looks like: <i:translate type="inplace"> <en>Pink</en> <fr>Rose</fr> <other>This color doesn't exists in your language!</other> <i:translate> As usual, markup inside <locale>'s is allowed. You can change the tag for the default translation using <default-other></> in the sitemap. I plan to add attributes for locale tags, something like: <en country="GB"... I send the whole new files and some tests. I haven't made a diff 'cause that's not clear it'll be useful for you to actually test and comment on it (i don't think either that it's ready for integration). -- "Black holes are where God divided by zero." - Steven Wright MaT|TaM
i18n.zip
Description: Zip archive
i18n-test.zip
Description: Zip archive
msg14721/pgp00000.pgp
Description: PGP signature