Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translating sortable headers #6

Open
mikecodona opened this issue Sep 26, 2014 · 1 comment
Open

Translating sortable headers #6

mikecodona opened this issue Sep 26, 2014 · 1 comment

Comments

@mikecodona
Copy link

I'm hoping to be able to be able to translate the titles for a sortable link. I was hoping I'd get away with the below but as the title isn't treated as a Django variable it obviously doesn't work.

{% trans "Arrive" as arrive_text %}
{% sortable_link arrive arrive_text %}

The render method of the SortableLinkNode could be changed to something along these lines:

  def render(self, context):
    url, css_class = self.build_link(context)

    try:
        title_var = template.Variable(self.title)
        title = title_var.resolve(context)
    except template.VariableDoesNotExist:
        title = self.title

    return '<a href="%s" class="%s" title="%s">%s</a>' % (url, css_class, title, title)

Is that something that you'd consider accepting as a pull request? Alternatively, is there a better way of doing it that I've missed?

@lnagel
Copy link

lnagel commented Mar 24, 2015

I've prepared a PR for this, because we really needed to have it running in our project.
See the PR here #7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants