I have faced the same issue: the datepicker ignored the language I 
specified ("hu" in this case), and was displayed in English instead.

I tried this, which did _not_ work:

<extend tag="bootstrap-datepicker">
>   <old-bootstrap-datepicker language="hu" merge/>
> </extend>
>
 
The issue seems to be a conflict of logic between hobo_bootstrap and 
hobo_bootstrap_ui.

The datepicker invocation code in hobo_bootstrap_ui 
https://github.com/Hobo/hobo_bootstrap_ui/blob/master/vendor/assets/javascripts/hobo-bootstrap-ui/bootstrap-datepicker.js#L2
 
takes the language from the document <html> element:

$('.bootstrap-datepicker').datepicker({ language: document.documentElement.
> lang });
>

However, the document <html> element in hobo_bootstrap 
https://github.com/Hobo/hobo_bootstrap/blob/master/taglibs/page.dryml#L31 
is hardcoded to 'en':

<html lang="en" merge-attrs>
>

The two together results in .datepicker() getting called with "en" 
regardless of any language settings, which seems to override the language 
preference specified for the input elements by the <bootstrap-datepicker> 
tag, resulting in the datepickers always getting displayed in English.

This can be fixed at three places:

   - hobo_bootstrap (recommended) - here is a PR to set the language of the 
   HTML element from I18n.locale: 
   https://github.com/Hobo/hobo_bootstrap/pull/43
   - hobo_bootstrap_ui (not recommended, but necessary if you need 
   datepickers to display in a language different than your <html> element 
   language) - here is a PR not to pick up the language from the HTML element: 
   https://github.com/Hobo/hobo_bootstrap_ui/pull/3
   - bootstrap-datepicker - one could argue here whether the language 
   specified for the .datepicker() function should or should not override the 
   per-element specified datepicker language, and also, whether the default 
   language should be English, or pick up the language from the <html> element 
   - I have submitted an issue for this: 
   https://github.com/Nerian/bootstrap-datepicker-rails/issues/108
   
2015. január 23., péntek 15:37:13 UTC+1 időpontban Ibon Castilla a 
következőt írta:
>
> -----BEGIN PGP SIGNED MESSAGE----- 
> Hash: SHA1 
>
> Hi Ignacio, 
>
> Thanks for the tip, it has worked! (kind of) :D 
>
> Before doing anything new, I've checked if I had already loaded the 
> snippet of code you suggest, and it was loaded! (loaded by front.js). 
> As it was being ignoring it, I tried adding the code you have 
> mentioned, but didn't seem to work either. 
> Finally I've found a workaround that seems to work nicely, consisting 
> in a combination of what you suggest and a little hack: 
>
> At application.dryml (reload the JS code that supports I18n): 
>
> <extend tag="page"> 
>   <old-page merge> 
>     <append-scripts:> 
>       <script> 
>       $.fn.datepicker.dates['es'] = { 
>         days: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", 
> "Viernes", "Sábado", "Domingo"], 
>         daysShort: ["Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb", 
> "Dom"], 
>         daysMin: ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do"], 
>         months: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", 
> "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", 
> "Diciembre"], 
>         monthsShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", 
> "Ago", "Sep", "Oct", "Nov", "Dic"], 
>         today: "Hoy", 
>         clear: "Borrar", 
>         weekStart: 1, 
>         format: "dd/mm/yyyy" 
>       }; 
>       </script> 
>     </append-scripts:> 
>   </old-page> 
> </extend> 
>
> At your view (the one that contains the input with 
> bootstrap-datepicker class on it): 
>
> <whatever-page> 
> ... 
>   <append-scripts:> 
>     <script> 
>     $( document ).ready(function() { 
>       jQuery('.bootstrap-datepicker').datepicker('remove'); 
>       jQuery('.bootstrap-datepicker').datepicker({language: 'es'}); 
>     }); 
>     </script> 
>   </append-scripts:> 
> ... 
> </whatever-page> 
>
> As I said, this is a workaround, but I think this problem deserves an 
> issue at Github, what do you think? :) 
>
> Many thanks and best regards, Ibon. 
>
> Abrazo, Ibon. 
>
> Usa Software Libre, tus úlceras te lo agradecerán 
> Realizado con Software Libre. 
> - -- 
> GPG public key at http://sinanimodelucro.net/ibon_gmail.asc 
> Finderprint: 1761 59B9 6DE6 0402 31B9 1872 178F A6FD 75F9 EB29 
>
> El 23/01/15 a las 13:18, Ignacio Huerta escribió: 
> > Hi Ibon, 
> > 
> > Please try adding this piece of Javascript before the datepicker 
> > is loaded, I think it might help: 
> > 
> > 
> https://github.com/eternicode/bootstrap-datepicker/blob/master/js/locales/bootstrap-datepicker.es.js
>  
> > 
> >  Warm regards, Ignacio 
> > 
> > El 22-01-2015 a las 10:19, Ibon Castilla escribió: 
> >> Hi everybody, 
> >> 
> >> I'm experiencing some trouble with bootstrap-datepicker 
> >> (
> http://hobocentral.net/tagdef/hobo_bootstrap_ui/hobo_bootstrap_ui/bootstrap-datepicker)
>  
>
> >> 
> >> 
> >> 
> I have tried different syntax in application.dryml but some options 
> >> are (apparently) being ignored. My actual code at 
> >> application.dryml is: 
> >> 
> >> <def tag='input' for='Date'> <bootstrap-datepicker language='es' 
> >> autoclose='false' format='dd/mm/yyyy)'/> </def> 
> >> 
> >> * Both "autoclose" and "format" work fine. * "language" is being 
> >> ignored completely. 
> >> 
> >> On the little research I've done on this, seems that the 
> >> language stuff is taken from Javascript, like in this sandbox: 
> >> 
> http://eternicode.github.io/bootstrap-datepicker/?markup=input&format=&weekStart=&startDate=&endDate=&startView=0&minViewMode=0&todayBtn=false&clearBtn=false&language=en&orientation=auto&multidate=&multidateSeparator=&keyboardNavigation=on&forceParse=on#sandbox
>  
> >> 
> >> 
> >> 
> Before going any further, I would like to know if anyone in this list 
> >> has faced this issue with bootstrap-datepicker previously, and if 
> >> so, if he/she would be so kind to give me a tip about it :) 
> >> 
> >> Best regards, Ibon. 
> >> 
> >> 
> > 
> -----BEGIN PGP SIGNATURE----- 
> Version: GnuPG v1.4.11 (GNU/Linux) 
>
> iEYEARECAAYFAlTCXJUACgkQF4+m/XX56ymREACgua31MYCFEM8xqkdA1YeUgz/+ 
> /L4An28TTSs7dijd4rDK4m133JaYeWFr 
> =yCxs 
> -----END PGP SIGNATURE----- 
>

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to