如何本地化配色系统

How can I localise colorbox?

本文关键字:系统 本地化      更新时间:2023-09-26

我在ROR应用程序中安装了Colorbox。但我需要本地化。在脚本中我有:

文件图像.js.coffee

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

其中{current}是当前图像,{total}是总图像。

如何从yml文件(app/config/locates/**.yml)粘贴数据?

您正在翻译一个jQuery插件。在vendor目录中执行,而不是在您的应用程序区域设置中执行。

jQuery ColorBox维护一个包含翻译的i18n目录:https://github.com/jackmoore/colorbox/tree/master/i18n

示例

/*
  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."
});

您可以下载一个并将其包含在colorbox之后(如果您使用git子模块,则可获得奖励)。

Rails >= 3.1示例

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

我使用gemhttps://github.com/fnando/i18n-js

它起作用了!

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