Move to maketext: sample templates

Vitaly Fedrushkov fedrushkov at users.sourceforge.net
Sun Jan 18 00:48:06 UTC 2009


Good $daytime,

Last Bugzilla meeting saw an improvised brainstorming session on how to 
keep template syntax easy when adding l10n support.  Thanks to everyone 
who contributed to discussion.

> 1. By far most annoying was the need for

>   [% l("text [_1]",value FILTER whatever,...) %]

Example 1:
https://bugzilla.mozilla.org/attachment.cgi?id=356254&action=diff#bugzilla-tip/template/en/default/account/profile-activity.html.tmpl_sec3

As is:
  <a href="editusers.cgi?action=edit&userid=
   [%- otheruser.id FILTER url_quote %]"
   title="Edit user '[% otheruser.login FILTER html %]'">Edit this user</a>

Variant 1.1: dumb
   [% otheruser_login = otheruser.login FILTER html %]
   [% edit_url = BLOCK %]<a href="editusers.cgi?action=edit&userid=
     [%- otheruser.id FILTER url_quote %]"
     title="[% l("Edit user '[_1]'", otheruser_login) %]">
   [% END %]
   [% |l(edit_url, "</a>") %]
     [_1]Edit this user[_2]
   [% END %]

Variant 1.2: introduce functions for 'FILTER html' and so on
   [% |l("<a href=\"editusers.cgi?action=edit&userid=" _
	  url_quote(otheruser.id) _ "\" title=\"" _
	  l("Edit user '[_1]'", html(otheruser.login)) _ "\">",
         "</a>") %]
     [_1]Edit this user[_2]
   [% END %]

Variant 1.3: introduce scalar operators for the same:
   [% |l("<a 
href=\"editusers.cgi?action=edit&userid=${otheruser.id.url_quote}\" 
title=\"" _
	  l("Edit user '[_1]'", otheruser.login.html) _ "\">",
         "</a>") %]
     [_1]Edit this user[_2]
   [% END %]

Variant 1.4: Leave basic HTML syntax within translated text:
   [% |l("editusers.cgi?action=edit&userid=${otheruser.id}"
	l("Edit user '[_1]'", otheruser.login)) %]
     <a href="[_1]" title="[_2]">Edit this user</a>
   [% END %]

In the latter case, each parameter can be html-filtered within 'l' 
filter implementation.

Will any of these improve readability and what option do you prefer?

   Regards,
   Vitaly.
_______________________________________________
dev-apps-bugzilla mailing list
dev-apps-bugzilla at lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-apps-bugzilla



More information about the developers mailing list