开发者

formtastic weird month name display

开发者 https://www.devze.com 2022-12-31 20:10 出处:网络
i\'m using formtastic, all is ok, but strange thing - on = form.input :birthdate, :as => :date it renders to something like

i'm using formtastic, all is ok, but strange thing - on

= form.input :birthdate, :as => :date 

it renders to something like

<li><label for="profile_birthdate_2i">Month</label><select
id="profile_birthdate_2i" name="profile[birthdate(2i)]">
    <option value="1">114</option>

    <option value="2">97</option>
    <option value="3">110</option>
    <option value="4">115</option>
    <option value="5">108</option>
    <option value="6">97</option>
    <option value="开发者_高级运维7">116</option>

    <option value="8">105</option>
    <option value="9">111</option>
    <option value="10">110</option>
    <option value="11">32</option>
    <option value="12">109</option>
    </select> 

but if i'm using in semantic_form something like

= form.datetime_select :birthdate 

it renders correctly. I've found information, that it may be caused by locale file with no translations for month names, but its so strange - why rails helpers renders month names ok, but formtastic - not :(

any ideas?


These numbers are ASCII codes for "ranslation m". The translations for the month names were not found so formtastic is using the string "translation missing..." (indexes 1 to 12) as month names (where each character is seen as an item from the char array).

To fix this you need the translations for the month names in your locales files, ie.:

en:
  date:
    month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
    abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号