Lightbox: how to translate 'Image x of x' text?

依然范特西╮ 提交于 2020-01-14 14:13:32

问题


I'm using Lightbox 2 for an image set. When a visitor of my website clicks on a thumbnail in that set, it'll show:

  • The enlarged version of the image
  • Underneath that: the description (taken from the <a> title attribute)
  • Underneath that: the text 'Image x of x' ('Image 1 of 12', for example)

Does anyone know where to translate/change the 'Image x of x' text? I've searched through the Lightbox script and CSS files, but can't find the text anywhere.

Some additional info: I'm not using Wordpress or Drupal or any other CMS. I've found some solutions for the issue above, but these all point to files that only seem come with the Lightbox plugins for these CMSes.


回答1:


Take a look in /js/lightbox.js at line 29-31:

LightboxOptions.prototype.albumLabel = function(curImageNum, albumSize) {
  return "Image " + curImageNum + " of " + albumSize;
};

Translate the strings in any language / text you want to.

Based on this version: https://github.com/lokesh/lightbox2/blob/master/js/lightbox.js




回答2:


With newer lightbox versions, you can use it like other options: Example:

lightbox.option({
    'resizeDuration': 200,
    'wrapAround': true,
    'showImageNumberLabel': true,
    'albumLabel': 'Bild %1 von %2',
});


来源:https://stackoverflow.com/questions/20759499/lightbox-how-to-translate-image-x-of-x-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!