Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#1076 closed defect (invalid)

[patch] Safari has a bug that prevents usage of JS i18n interpolate function

Reported by: hugo Owned by: hugo
Component: Internationalization Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Safari has a bug in handling string.replace with a function as the second parameter. That leads to weird output or no translation. This bug needs to be fixed on Safaris side of the things though - unless someone finds a solution in pure JavaScript that works on all browsers (and is fast enough). Yes, the bug is filed for Safari. So this is either to remind me that the problem exist or to find a workaround (if fixing Safari takes too long).

Attachments (3)

django.i18n.patch (1.0 KB) - added by eugene@… 9 years ago.
django.i18n.2.patch (1.0 KB) - added by eugene@… 9 years ago.
django.i18n.3.patch (1.0 KB) - added by eugene@… 9 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 9 years ago by hugo

  • Status changed from new to assigned

comment:2 Changed 9 years ago by eugene@…

  • Summary changed from Safar has a bug that prevents usage of JS i18n interpolate function to Safari has a bug that prevents usage of JS i18n interpolate function

comment:3 Changed 9 years ago by eugene@…

I don't think it is a bug. Only recent versions of JavaScript (1.5?) allows functions as replace() parameter. Before that and from the dawn of times the 2nd parameter should be a string.

comment:4 Changed 9 years ago by hugo

Safari is a rather recent browser and claims to support those recent JavaScript functionality, so it should really support it. Otherwise it is a bug :-)

But feel free to send me a patch that accomplishes the same without using the function as the second argument.

comment:5 Changed 9 years ago by hugo

Oh, according to the ECMAScript standard, replace with a function as second argument is supported since ECMAScript v3 - and that's from 1999. So that would be enough time for Safari to pick up that feature, don't you think? ;-)

Changed 9 years ago by eugene@…

comment:6 Changed 9 years ago by eugene@…

I just threw together a patch. I didn't test it --- I don't have Safari. I deliberately didn't use Array.push() because I don't remember, if it is understood by Safari. There is a commented-out if. I hope you don't need it but if you have a problem with border conditions, you should do something along these lines.

Try it, test border conditions, remove the cruft, and i18n should be okay. If there ia a problem, just let me know.

comment:7 Changed 9 years ago by eugene@…

  • Summary changed from Safari has a bug that prevents usage of JS i18n interpolate function to [patch] Safari has a bug that prevents usage of JS i18n interpolate function

comment:8 Changed 9 years ago by eugene@…

Stop the press: String.split() behaves differently in different browsers. Let me edit the patch.

Changed 9 years ago by eugene@…

Changed 9 years ago by eugene@…

comment:9 Changed 9 years ago by eugene@…

Try the last one.

comment:10 Changed 9 years ago by hugo

Since the bug is resolved in Safari top-of-the-trunk (just got the note from the Safari bugzilla), I think we better wait wether they are about to release a new version (seems likely with all the SVG stuff they did integrate). If they take too long, we can allways go with your patch. thx for that.

comment:11 Changed 9 years ago by jacob

  • Resolution set to invalid
  • Status changed from assigned to closed

Since this is fixed in Safari I'm marking INVALID -- whenever possible, let's not hack around browser bugs :)

Note: See TracTickets for help on using tickets.
Back to Top