Opened 19 years ago

Closed 19 years ago

Last modified 18 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: no UI/UX: no

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@… 19 years ago.
django.i18n.2.patch (1.0 KB ) - added by eugene@… 19 years ago.
django.i18n.3.patch (1.0 KB ) - added by eugene@… 19 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by hugo, 19 years ago

Status: newassigned

comment:2 by eugene@…, 19 years ago

Summary: Safar has a bug that prevents usage of JS i18n interpolate functionSafari has a bug that prevents usage of JS i18n interpolate function

comment:3 by eugene@…, 19 years ago

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 by hugo, 19 years ago

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 by hugo, 19 years ago

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? ;-)

by eugene@…, 19 years ago

Attachment: django.i18n.patch added

comment:6 by eugene@…, 19 years ago

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 by eugene@…, 19 years ago

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

comment:8 by eugene@…, 19 years ago

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

by eugene@…, 19 years ago

Attachment: django.i18n.2.patch added

by eugene@…, 19 years ago

Attachment: django.i18n.3.patch added

comment:9 by eugene@…, 19 years ago

Try the last one.

comment:10 by hugo, 19 years ago

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 by Jacob, 19 years ago

Resolution: invalid
Status: assignedclosed

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