最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Lightbox: how to translate 'Image x of x' text? - Stack Overflow

programmeradmin4浏览0评论

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.

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.

Share Improve this question edited Dec 24, 2013 at 11:02 ztirom 4,4383 gold badges29 silver badges39 bronze badges asked Dec 24, 2013 at 10:46 Edward TouwEdward Touw 8131 gold badge7 silver badges10 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 18

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',
});

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

You can also just use the global object to set the value:

let category = 'Flowers';
lightbox.options.albumLabel = 'Image %1 of %2 - ' + category;
发布评论

评论列表(0)

  1. 暂无评论