Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#10278 closed defect (bug) (fixed)

thickbox.js strings are not i18n

Reported by: xibe Owned by: azaozz
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.8
Component: I18N Keywords: has-patch tested
Focuses: Cc:


Plugins are starting to rely on WP's own set of included JS libs, and therefore are dropping their translation for these libs' strings.

For instance, NextGEN Gallery is now using WP's ThickBox lib rather than including its own version, and WP's contains the following non-i18n strings - which, therefore, appear in English in all cases:

line 87:

TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";

line 90:

TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";

line 95:

TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length);

line 129 (title is 'Close'):

jQuery("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'><img src='" + tb_closeImage + "' /></a></div>"); 

Note that:

  • there might be others in this file, I only did a quick survey following this report on the WPFR forums ;
  • other included libraries might also have non-i18n strings, which should be tracked down.

Attachments (1)

i18n-thickbox.diff (9.7 KB) - added by nbachiyski 11 years ago.

Download all attachments as: .zip

Change History (11)

#1 @xibe
11 years ago

  • Keywords needs-patch added

#2 @nbachiyski
11 years ago

  • Keywords has-patch added; needs-patch removed
  • Owner changed from nbachiyski to azaozz
  • Status changed from new to reviewing

I found some more instances of Close, but that was pretty much it. The patch is attached.

#3 follow-up: @TobiasBg
11 years ago

Nice patch. One small error though:
"swfuploadL10n" shall probably be "thickboxL10n"
in the line

'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};'

of the patched wp-includes/script-loader.php

#4 in reply to: ↑ 3 @nbachiyski
11 years ago

Replying to TobiasBg:

Nice patch. One small error though:
"swfuploadL10n" shall probably be "thickboxL10n"

Bad, copy/paste, bad.


#5 @TobiasBg
11 years ago

Maybe the localization can also be used to fix #6453 (see my first suggestion there).

#6 @azaozz
11 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

(In [12276]) l10n for thickbox.js, props nbachiyski, fixes #10278

#7 @hakre
11 years ago

  • Keywords tested added

Tested in the wild against new translation and looks good so far.

#8 @rodrigovolponi
10 years ago

  • Cc rodrigovolponi added
  • Keywords 2nd-opinion added

This patch seems to not work, at least using WP 3.0.1 as the bug have described (NextGEN plugin using Wordpress' lib thickbox.js).

The output of the template is always like this, always not translated):

<script type='text/javascript'>
/* <![CDATA[ */
var thickboxL10n = {
	next: "Next &gt;",
	prev: "&lt; Prev",
	image: "Image",
	of: "of",
	close: "Close",
	noiframes: "This feature requires inline frames. You have iframes disabled or your browser does not support them."
/* ]]> */

It is true for every script loaded by script-loader.php. For instance, at the "wp-admin/post-new.php", all the scripts called by script-loader.php are not translated. There is one exception: autosaveL10n.

I have two installations on different servers using the current Wordpress version (3.0.1) and the pt-br i18n. It is possible to confirm the proper translation is found at .po and .mo files. I have tested the output of the string sucessfully inside the loop of a regular theme:

_e('Next &gt;'); // Outputs "Próximo &raquo;" correctly

I'm not sure if it is happening just with me, so I'd like to have confirmation that this translation is actually happening properly.

#9 @nbachiyski
10 years ago

rodrigovolponi, probably you have a plugin, which calls wp_enqueue_script() before init. I looked at the latest version of NextGEN and its code looks alright, so it must be another plugin.

Could you disable all other plugins and try again?

#10 @rodrigovolponi
10 years ago

  • Keywords 2nd-opinion removed

nbachiyski, you are right. I've disabled all the plugins and the one that is causing this problem is "WP Carrousel" (http://wordpress.org/extend/plugins/wp-carousel/).

I'll try to contact the developer and report this problem.

Note: See TracTickets for help on using tickets.