Internationalization of Date Selector

17 views
Skip to first unread message

Donald R. Ziesig

unread,
Jun 3, 2011, 7:11:14 PM6/3/11
to hobo...@googlegroups.com
Hi All:

I am adding Spanish to my Real Estate Web site. All is going well
except when I try to use a date selector (Drop down lists for year,
month, day).

The English one works fine (e.g. 2011 06 03) with the months ranging
from 01 .. 12.

The Spanish one gives strange values for the month (e.g. 2011 97 03)
with the months in the values [114, 97, 110, 115, 108, 97, 116, 105,
111, 110, 32, 109].

I put the ascii values in parens to see if there was any kind of pattern
there, but it found none:

Enero 114 (s)
Febrero 97 (a)
Marzo 110 (n)
Abril 115 (t)
Mayo 108 (l)

etc.

I don't care if I get valid numbers or valid names in the month list.
What do I need in app.es.yml to make this work?

Thanks,

Don Z.


Ignacio Huerta

unread,
Jun 12, 2011, 11:56:05 AM6/12/11
to hobo...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I've translated a bunch of Hobo apps to spanish. I have never used the
default Date select widgets, I really prefer the Jquery Datepicker. It's
very easy to install with Hobo Jquery:

http://cookbook.hobocentral.net/plugins/hobo-jquery
http://cookbook.hobocentral.net/api_tag_defs/hjq-datepicker

And later you can translate it like this:

<def tag="input" for="Date">
<hjq-datepicker dayNamesMin="&['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa']"
dateFormat="dd-mm-yy"
firstDay="1"
monthNames="&['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio',
'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre']"
monthNamesShort="&['Ene', 'Feb', 'Mar', 'Abr','May', 'Jun', 'Jul',
'Ago', 'Sep', 'Oct', 'Nov', 'Dic']" merge />
</def>

Not directly related, but I have some other spanish date translation
tips for Hobo 1.0.1. This initializer helps a lot:
config/initializers/date_formats.rb

Date::DATE_FORMATS[:default] = "%d-%m-%Y"
Date::DATE_FORMATS[:slashed] = "%d/%m/%Y"
Date::DATE_FORMATS[:short] = "%d de %b"
Date::DATE_FORMATS[:long] = "%e de %B de %Y"
Time::DATE_FORMATS[:long] = "%e de %B de %Y a las %k:%M"


Maybe you are also interested in a custom L10n-simplified plugin. Just
download this:
http://ihuerta.net/wp-content/uploads/2011/06/L10n-simplified-0.9-uyc.tar.gz.
Extract it in vendor/plugins and add the following line con
config/environment.rb before "Rails::Initializer.run do |config|"

L10N_LANG = :es


Hope it helps :)

Regards,
Ignacio

El 04/06/11 01:11, Donald R. Ziesig escribi�:

- --
Ignacio Huerta Arteche
http://www.ihuerta.net
Tel�fono: 0034 645 70 77 35
Email realizado con software libre
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk304ZUACgkQBPlUJ6RHaOR4owCg2BOqF4n0f9vvq+A8hoZoxmfM
8egAnjjiSPfyPgYnGiZHCRtKm/IGrgU8
=LL+m
-----END PGP SIGNATURE-----

Ronny Hanssen

unread,
Jun 12, 2011, 12:52:40 PM6/12/11
to hobo...@googlegroups.com
I'd start with adding the "standard" rails locale support for es via: https://github.com/svenfuchs/rails-i18n#readme

"Download the locale files that are found in the directory rails/locale and put them into the config/locales directory of your Rails application.

If any translation doesn't suit well to the requirements of your application, edit them or add your own locale files."


These files contain amongst others translations for dates and stuff.

I myself use the hobo-jQuery plugin and the jQuery datepicker with great success. Had to add some extra translations for the date-picker, but other than that I am happy.


Regards
~Ronny
Reply all
Reply to author
Forward
0 new messages