I installed Colorbox in my ROR application. But I need localisation. In the script i have:
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.
How to paste data from yml-file (app/config/locales/**.yml)?
I installed Colorbox in my ROR application. But I need localisation. In the script i have:
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.
How to paste data from yml-file (app/config/locales/**.yml)?
Share Improve this question edited Aug 22, 2012 at 11:13 user1466717 asked Aug 22, 2012 at 11:08 user1466717user1466717 7891 gold badge10 silver badges24 bronze badges 1- I tried "{current} t('views.image.of') {total}" and "{current}" + t('views.image.of') + "{total}" and "{current} i18n.t('views.image.of') {total}" and "{current}" + i18n.t('views.image.of') + "{total}" – user1466717 Commented Aug 22, 2012 at 11:10
2 Answers
Reset to default 7You are translating a jQuery plugin. Do it within the vendor
directory, not in your application locales.
jQuery ColorBox maintains a i18n
directory with translations:
https://github./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).
Example with Rails >= 3.1
//= require jquery.colorbox
//= require jquery.colorbox-es
I use gem https://github./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}"})