Dev talk:HiEngine

From Habari Project

Jump to: navigation, search

One of the main pieces missing from hiengine is a way to echo translated text using hiengine template tags. There are three major ways that text is output in themes:

  • A string of plain text, such as
    <?php _e('Edit'); ?>
  • A string with parameters, such as
    <?php _e( 'There have been %d comments', array($posts_1->comments->approved->count ) ); ?>
  • A function that outputs text depending on the count of a given number. This is usually used in the form
    <?php echo _n( 'Comment', 'Comments', $posts_1->comments->approved->count ); ?>

In irc we have discussed possible ways to cope with the first two of these. Two main ideas were agreed on as possibilities:

  • One uses a begin and end tag marker in the form {hi:translate}There have been {hi:foo} comments on the post.{/hi:translate}. Simple text would just be {hi:translate}Edit Post{/hi:translate}. There are several reasonable possibilities for the actual tag: translate, out, echo, print being among the most self-evident.
  • One uses only quotes in the form {hi:"This post has been viewed {hi:foo} times by {hi:bar} people"}. The benefit of this is the lack of an actual alphabetic tag, replacing it with the obvious quotes. A variation on this would be {"This post has been viewed {hi:foo} times by {hi:bar} people}. IMO the lack of a beginning '{hi' may be confusing, though, lacking symmetry with the remainder of the hiengine template tags.

There was one other proposal by mikelietz. This entailed simply putting a tag like {hi:views} (in the case of the example used above) in the actual template, and defining the settings for views somewhere else. This looks to me closely similar to defining a function in the theme's class, then just calling the function like any other function. It has the benefit of keeping code out of the templates, but requires defining functions for each and every _e() that is currently used in theme templates. This may not be a bad idea, since it keeps templates clean and simple, all theme's I've seen to date require some sort of class definition for a theme so the themer has to have some degree of php knowledge, and may end up having to be done to deal with _n() calls. On the other hand, creating a tag to output parameterized text is a more general solution that leads to easy to learn templating and helps minimize code in the class definition.

--rickc 04:21, 18 November 2008 (UTC)

Personal tools