Modify

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#13992 closed defect (fixed)

Create Jinja2 templates

Reported by: Cinc-th Owned by: Cinc-th
Priority: normal Component: CustomFieldAdminPlugin
Severity: normal Keywords:
Cc: Ryan J Ollos Trac Release: 1.4

Description

Use of Genshi is deprecated and no longer supported with Trac > 1.5.

Convert template to Jinja2.


@rjollos:

Should I attach a patch or will you give me (temporary) write access to this plugin?

Attachments (1)

t13992-jinja2-l10n.diff (8.1 KB) - added by Jun Omae 3 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 in reply to:  description Changed 3 years ago by Ryan J Ollos

Replying to Cinc-th:

Should I attach a patch or will you give me (temporary) write access to this plugin?

rw access granted for entire repository. Please feel free to proceed with any commits after confirming checking with the plugin author, of which very few are around these days.

comment:2 Changed 3 years ago by Ryan J Ollos

Owner: changed from osimons to Cinc-th
Status: newassigned

comment:3 Changed 3 years ago by Cinc-th

Resolution: fixed
Status: assignedclosed

In 18134:

CustomFieldAdminPlugin: use Jinja2 for Trac >= 1.3.

Closes #13992

comment:4 Changed 3 years ago by Jun Omae

I think we should create 1.4 branch requiring Trac>=1.3 and unable to make compatible with both 1.4 and 1.2.

comment:5 in reply to:  4 Changed 3 years ago by Jun Omae

I think we should create 1.4 branch requiring Trac>=1.3 and unable to make compatible with both 1.4 and 1.2.

Ah, sorry. I misunderstood commit message. The changes seem to be compatible with both 1.4 and 1.2.

Minor thing, we could check jenv attribute without creating a Chrome instance.

-        if hasattr(Chrome(self.env), 'jenv'):
+        if hasattr(Chrome, 'jenv'):

Changed 3 years ago by Jun Omae

Attachment: t13992-jinja2-l10n.diff added

comment:6 Changed 3 years ago by Jun Omae

L10N with Trac 1.4.x doesn't work.

-    <h2>${_("Manage Custom Fields")}</h2>
+    <h2>${dgettext(domain, "Manage Custom Fields")}</h2>

We should use dgettext() instead of _() in templates of plugins.

-            return 'customfieldadmin_jinja.html', cf_admin, {'domain': 'customfieldadmin'}
+            cf_admin['domain'] = 'customfieldadmin'
+            return 'customfieldadmin_jinja.html', cf_admin

Also, 3rd parameter shouldn't be used. Otherwise, dgettext() leads the following exception.

    <h2>${dgettext(domain, "Manage Custom Fields")}</h2>
  File "/home/jun66j5/venv/trac/1.4.2/local/lib/python2.7/site-packages/trac/util/translation.py", line 295, in <lambda>
    return lambda *args, **kw: _functions[symbol](domain, *args, **kw)
KeyError: 'dgettext'

attachment:t13992-jinja2-l10n.diff

comment:7 Changed 3 years ago by Cinc-th

<h2>${_("Manage Custom Fields")}</h2> works for me. I see the german translations on my system.

And it's what's described here: trac:TracDev/PortingFromGenshiToJinja#trans

But I'm no expert here...

Last edited 3 years ago by Ryan J Ollos (previous) (diff)

comment:8 Changed 3 years ago by anonymous

Hi All,

I am on Trac 1.5.3 using this plugin:

Fix for me was

+            cf_admin['domain'] = 'customfieldadmin'
+            return 'customfieldadmin_jinja.html', cf_admin

This did not fix the issue:

<h2>${_("Manage Custom Fields")}</h2>

comment:9 Changed 3 years ago by anonymous

Resolution: fixed
Status: closedreopened

See above for 1.5.x fix

comment:10 Changed 3 years ago by Ryan J Ollos

Resolution: fixed
Status: reopenedclosed

In 18455:

CustomFieldAdminPlugin: Fix "KeyError: dngettext"

Extract messages and update catalogs.

Patch by Jun Omae.

Fixes #13992, #14056.

comment:11 Changed 3 years ago by Ryan J Ollos

In 18456:

CustomFieldAdminPlugin: Use dgettext everywhere

Patch by Jun Omae.

Refs #13992.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Cinc-th.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.