Skip to content

Make timezoneList translatable. #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

apepper
Copy link
Contributor

@apepper apepper commented Mar 20, 2012

  • Added english default translation

  • Added german translation

  • Usage:

    $('input.datetimepicker').datetimepicker({
         showTimezone: true,
         timezoneList: [
           {"value": "-1100", "label": "minusEleven"},
           {"value": "-1000", "label": "minusTen"},
           {"value": "-0900", "label": "minusNine"},
           {"value": "-0800", "label": "minusEight"},
           {"value": "-0700", "label": "minusSeven"},
           {"value": "-0600", "label": "minusSix"},
           {"value": "-0500", "label": "minusFive"},
           {"value": "-0400", "label": "minusFour"},
           {"value": "-0300", "label": "minusThree"},
           {"value": "-0200", "label": "minusTwo"},
           {"value": "-0100", "label": "minusOne"},
           {"value": "+0000", "label": "plusMinusZero"},
           {"value": "+0100", "label": "plusOne"},
           {"value": "+0200", "label": "plusTwo"},
           {"value": "+0300", "label": "plusThree"},
           {"value": "+0400", "label": "plusFour"},
           {"value": "+0500", "label": "plusFive"},
           {"value": "+0600", "label": "plusSix"},
           {"value": "+0700", "label": "plusSeven"},
           {"value": "+0800", "label": "plusEight"},
           {"value": "+0900", "label": "plusNine"},
           {"value": "+1000", "label": "plusTen"},
           {"value": "+1100", "label": "plusEleven"},
           {"value": "+1200", "label": "plusTwelve"},
           {"value": "+1300", "label": "plusThirteen"}
           ]
    

* Added english default translation
* Added german translation
* Usage:
$('input.datetimepicker').datetimepicker({
    showTimezone: true,
    timezoneList: [
      {"value": "-1100", "label": "minusEleven"},
      {"value": "-1000", "label": "minusTen"},
      {"value": "-0900", "label": "minusNine"},
      {"value": "-0800", "label": "minusEight"},
      {"value": "-0700", "label": "minusSeven"},
      {"value": "-0600", "label": "minusSix"},
      {"value": "-0500", "label": "minusFive"},
      {"value": "-0400", "label": "minusFour"},
      {"value": "-0300", "label": "minusThree"},
      {"value": "-0200", "label": "minusTwo"},
      {"value": "-0100", "label": "minusOne"},
      {"value": "+0000", "label": "plusMinusZero"},
      {"value": "+0100", "label": "plusOne"},
      {"value": "+0200", "label": "plusTwo"},
      {"value": "+0300", "label": "plusThree"},
      {"value": "+0400", "label": "plusFour"},
      {"value": "+0500", "label": "plusFive"},
      {"value": "+0600", "label": "plusSix"},
      {"value": "+0700", "label": "plusSeven"},
      {"value": "+0800", "label": "plusEight"},
      {"value": "+0900", "label": "plusNine"},
      {"value": "+1000", "label": "plusTen"},
      {"value": "+1100", "label": "plusEleven"},
      {"value": "+1200", "label": "plusTwelve"},
      {"value": "+1300", "label": "plusThirteen"}
      ]
@trentrichardson
Copy link
Owner

Hey apepper, I like where you're going with this, but I would suggest making a slight change. First I think we could leave the timezone list as is:

$('input.datetimepicker').datetimepicker({
    showTimezone: true,
    timezoneList: [
        "-1100",
        "-1000",
        "-0900",
        "-0800",
        "-0700",
        "-0600",
        "-0500",
        "-0400",
        "-0300",
        "-0200",
        "-0100",
        "+0000",
        "+0100",
        "+0200",
        "+0300",
        "+0400",
        "+0500",
        "+0600",
        "+0700",
        "+0800",
        "+0900",
        "+1000",
        "+1100",
        "+1200",
        "+1300"
    ]
});

But instead of the extra key mapping we use the "-1100" as the key map to the regional timezone labels. This will be more compact and if the label doesn't exist just show the values. So our regional value will resemble:

this.regional[''] = { // Default regional settings
    currentText: 'Now',
    closeText: 'Done',
    ampm: false,
    amNames: ['AM', 'A'],
    pmNames: ['PM', 'P'],
    timeFormat: 'hh:mm tt',
    timeSuffix: '',
    timeOnlyTitle: 'Choose Time',
    timeText: 'Time',
    hourText: 'Hour',
    minuteText: 'Minute',
    secondText: 'Second',
    millisecText: 'Millisecond',
    timezoneText: 'Time Zone',
    timezoneLabels: {
        '-1100': '-11h NUT: Niue Time',
        '-1000': '-10h HST: Hawaii Standard Time',
        '-0900': '-09h HDT: Hawaii Summer Time',
        '-0800': '-08h PST: Pacific Standard Time',
        '-0700': '-07h PDT: Pacific Summer Time',
        '-0600': '-06h CST: Central Standard Time (America)',
        '-0500': '-05h EST: Eastern Standard Time (America)',
        '-0400': '-04h EDT: Eastern Summer Time (America)',
        '-0300': '-03h BRT: Brasilia Standard Time',
        '-0200': '-02h BRST: Brasilia Summer Time',
        '-0100': '-01h CVT: Cape Verde Time',
        '+0000': '±00h UTC: Universal Coordinated Time (Greenwich)',
        '+0100': '+01h CET: Central European Standard Time',
        '+0200': '+02h CEST: Central European Summer Time',
        '+0300': '+03h AST: Arabia Time',
        '+0400': '+04h MSK: Moscow Time',
        '+0500': '+05h PKT: Pakistan Time',
        '+0600': '+06h BST: Bangladesh Time',
        '+0700': '+07h ICT: Indochina Time',
        '+0800': '+08h CST: China Standard Time',
        '+0900': '+09h JST: Japan Time',
        '+1000': '+10h AEST: Australian Eastern Standard Time',
        '+1100': '+11h AEDT: Australian Eastern Summer Time',
        '+1200': '+12h NZST: New Zealand Standard Time',
        '+1300': '+13h NZDT: New Zealand Summer Time'
    }
};

@apepper
Copy link
Contributor Author

apepper commented Mar 20, 2012

sounds good. I'll try that and update this pullrequest once I'm done.

@trentrichardson
Copy link
Owner

Sorry, This currently already was implemented, the format was just a bit different and you can also include timezoneList in the regional file. The timezoneList can be either an array: [ '+0400', '+0500', ....] or an object:

timezoneList: [
    { value: '+0400', label: 'EST' },
    { value: '+0500', label: 'CST' },
    { value: '+0600', label: 'MST' },
    { value: '+0700', label: 'PST' },
]

However this does not allow for setting the timeformat option for displaying the label. The code in my example above would allow for displaying the timezone label pretty easily, just using timezoneLabels['+0000']. The current implementation would need to do a loop through all values to find the current one. Wouldn't be difficult, just inefficient..

@apepper
Copy link
Contributor Author

apepper commented Mar 20, 2012

See my new commit 5128f9b.

@trentrichardson
Copy link
Owner

I've been looking over the current implementation and am trying to decide if it needs changing. Currently (I had forgotten how it worked, it had been long ago when it was implemented) that you could already pass in labels, so I don't know that anything is gained by reworking it.

Sorry if my previous comment was too late and you had already reworked it.

The only other thing I can think of to tweak timezones is to allow adding a timeFormat option for the timezone labels. My stance on that at the moment is there have been no feature requests for this, and trying to parse an unknown string format may be highly unpredictable.. so for now I think we leave as is.

Were you trying to solve a problem I am not catching on to?

@apepper
Copy link
Contributor Author

apepper commented Mar 21, 2012

Ah, now I see. I didn't know, that you can also place the timezoneList with the different translations. I just tried it and it works like intended. Maybe the documentation could be extended to make it easier to find stuff like this.

@apepper apepper closed this Mar 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants