bevacqua / rome

:calendar: Customizable date (and time) picker. Opt-in UI, no jQuery!
https://bevacqua.github.io/rome
MIT License
2.91k stars 223 forks source link

Locale #154

Closed deduka closed 8 years ago

deduka commented 8 years ago

This is not issue, but question. Please forgive me, because i am an beginner. :) I want to setup locale for my language bosnian (bs). this is my code:

<link href='rome.css' rel='stylesheet' type='text/css' />
<script src='rome.js'></script>

<input type="text" id="datepicker1">
<input type="text" id="datepicker2">

<script>

    var picker = new rome(document.getElementById('datepicker1'),
        {
            time: false,
            initialValue: '01.01.2015', 
            inputFormat: 'DD.MM.YYYY'
        } );
    var picker = new rome(document.getElementById('datepicker2'),
        {
            time: false,
            initialValue: '01.01.2015', 
            inputFormat: 'DD.MM.YYYY'
        } );

</script>

What and where I need to add? Thanks.

bevacqua commented 8 years ago

See here: https://github.com/bevacqua/rome#setup

You'll need to configure moment, which supports internationalization.

deduka commented 8 years ago

can you give me an example? thanks.

ghost commented 8 years ago

hi Deduka, did you find a solution to your problem? I have the same problem I don't find how to configure Moment for Rome

ghost commented 8 years ago

ok, I found. You have to call moment from rome and probably import (or require) a moment locale.

import m from 'mithril';
import Moment from 'moment';
import Rome from 'rome';
import 'moment/locale/fr';

const SideBar = {};
SideBar.controller = function(attrs){
    var controller = {};
    var today = Moment().format('DD-MM-YYYY');
    Rome.moment.locale('fr');
    controller.startDateField=function(el,isInitialized){
        if(!isInitialized){
            Rome(el,{dateValidator:Rome.val.beforeEq(end),inputFormat:"DD-MM-YYYY",max:today,time:false,weekStart:1}).on('data',function(value){
                attrs.start(value);
            });
        }
    };
    return controller;
};
SideBar.view = function(ctrl,attrs){
    return m("div",{class:"nav navbar-nav side-nav well"},[
        m("form",{role:"form"},[
            m("div",{class:"form-group"},[
                m("label",{for:"start",class:"control-label"}, "Début de la période "),
                m('input',{type:'text',id:'start',config: ctrl.startDateField})
            ]),
            m("input",{type:"button", class:"btn btn-info btn-sm",name:"interval", value:"valider",onclick:ctrl.clickButton})
        ])
    ])
};
export default SideBar;

I use mithril and jspm "el" is like getElement... and import is like require. You can use weekStart option to begin the week at monday in place on sunday.

(sorry for my lows skills in english speaking)

deduka commented 8 years ago

Rome doesn't work in IE, therefore I gived up! To bad. :( I give chance to Pikaday. It works in IE, but doesn't support validation, so you need to implement your own, with additional javascript function.

ghost commented 8 years ago

Oh effectively! Not essential to me but docs says: "Browser support includes every sane browser and IE7+.", hum! Good luck with Pikaday and thanks for your response Deduka.

deduka commented 8 years ago

I tryed it on IE8 and something messed up with css, calendar box was widespread over whole screen. On Firefox and Chrome works correctly. For datepicker, Rome is the best solution i've seen, but IE is peace of s..t and nothing works correctly. I hope Rome will be more stable with IE in newer version.

ROBERT-MCDOWELL commented 5 years ago

works smoothly on IE8+ for me, I had to fix some cosmetics though.