简体   繁体   English

我该如何本地化colorbox?

[英]How can I localise colorbox?

I installed Colorbox in my ROR application. 我在我的ROR应用程序中安装了Colorbox。 But I need localisation. 但我需要本地化。 In the script i have: 在脚本中我有:

file images.js.coffee file images.js.coffee

$(document).ready ->
          $(".group1").colorbox({rel:'group1',
 transition:"none", maxWidth:"85%", maxHeight:"85%",
 current: "{current} <%= t('views.image.of') %> {total}"})

where {current} is current image and {total} are total images. 其中{current}是当前图像,{total}是总图像。

How to paste data from yml-file (app/config/locales/**.yml)? 如何从yml文件中粘贴数据(app / config / locales / **。yml)?

You are translating a jQuery plugin. 您正在翻译jQuery插件。 Do it within the vendor directory, not in your application locales. vendor目录中执行,而不是在应用程序区域设置中执行。

jQuery ColorBox maintains a i18n directory with translations: https://github.com/jackmoore/colorbox/tree/master/i18n jQuery ColorBox维护一个带有翻译的i18n目录: https//github.com/jackmoore/colorbox/tree/master/i18n

Example

/*
  jQuery ColorBox language configuration
    language: Spanish (es)
    translated by: migolo
*/
jQuery.extend(jQuery.colorbox.settings, {
    current: "Imagen {current} de {total}",
    previous: "Anterior",
    next: "Siguiente",
    close: "Cerrar",
    xhrError: "Error en la carga del contenido.",
    imgError: "Error en la carga de la imagen."
});

You can download one and include it after colorbox (bonus points if you use git submodules ). 您可以下载一个并将其包含在colorbox之后(如果使用git子模块,则可获得奖励积分)。

Example with Rails >= 3.1 Rails >= 3.1示例Rails >= 3.1

//= require jquery.colorbox
//= require jquery.colorbox-es

I use gem https://github.com/fnando/i18n-js 我使用gem https://github.com/fnando/i18n-js

It's works! 其作品!

$(document).ready ->
      $(".group1").colorbox({rel:'group1',
          transition:"none", maxWidth:"85%", maxHeight:"85%",
           current: "{current} <%= I18n.t('views.image.of') %> {total}"})

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

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