简体   繁体   English

Lightbox:如何翻译“Image x of x”文本?

[英]Lightbox: how to translate 'Image x of x' text?

I'm using Lightbox 2 for an image set.我将 Lightbox 2 用于图像集。 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)在那之下:描述(取自<a> title 属性)
  • Underneath that: the text 'Image x of x' ('Image 1 of 12', for example)在其下方:文本“X 的图像 x”(例如,“12 的图像 1”)

Does anyone know where to translate/change the 'Image x of x' text?有谁知道在哪里翻译/更改“Image x of x”文本? I've searched through the Lightbox script and CSS files, but can't find the text anywhere.我搜索了 Lightbox 脚本和 CSS 文件,但无法在任何地方找到文本。

Some additional info: I'm not using Wordpress or Drupal or any other CMS.一些附加信息:我没有使用 Wordpress 或 Drupal 或任何其他 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.我已经找到了针对上述问题的一些解决方案,但这些都指向似乎仅随这些 CMS 的 Lightbox 插件一起提供的文件。

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 : 第29-31行查看/js/lightbox.js

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 基于此版本: https//github.com/lokesh/lightbox2/blob/master/js/lightbox.js

You can also just use the global object to set the value:您也可以只使用全局 object 来设置值:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM