Martin Atkins (mart) wrote in lj_dev,
Martin Atkins

Partial overriding of S2 hash properties

Some layouts (probably just A Sturdy Gesture, actually) use hashes for some translation strings to make the code easier later. A Sturdy Gesture, for example, uses two hashes to deal with the labels on the links for entries and comments. (which should really be in core or supplied by the backend from the translation system, but I digress.)

The problem comes when new links are added in future, causing the parent layer to have a new hash key added. Child layers (i18n or i18nc layers) will still lack the extra key, so journals in that language will lack one of the text items probably leading to a blank link.

What I'm proposing this time is that we allow hash properties to optionally do “partial overriding”. This involves changing make_context to pick up on a property attribute partial_override and, rather than just assigning the new hashref, actually copy the keys one-by-one into the existing hashref, meaning that any keys which are not overriden remain in their English form. This isn't ideal, of course, but it's better than no string at all. It can be an option which is off by default since it's obviously faster to just assign the new hashref and probably desirable in some cases.

Sound good?


  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded