vecnehladny / ubersicht-ios-clock-upnext-weather

A simple iOS styled widget section for Übersicht
10 stars 4 forks source link

No localisation. Unable to translate #2

Open etrahretep opened 4 years ago

etrahretep commented 4 years ago
Schermafbeelding 2020-04-30 om 18 20 22

The "Whole day" events are hour-events but don't show like that. Evens with location are not shown. Except for day after. Using latest version of Catalina, version 1.10.1 iCalbuddy. Language is Dutch. Other issues: no localisation of weather state (added the &lang=#{lang} in the curl command) Would like localisation of date too!

Hope you can help me out!

coolajami commented 4 years ago

@etrahretep

  1. for the weather widget, see the screenshot below, replace the ".main" extension in line 36, with ".description" should do the trick with "lang" addition in the curl command as you described. Screenshot 2020-05-01 at 15 20 52
  2. for the iCal widget, currently the location act as the separator between the all-day events and the time-specific events. So in your native macOS, all the events that marked as all-day events should NOT have a location declared, where all the time-specific events SHOULD HAVE a location declared. if the time-specific events do not have a location, then will apear as whole day events in the widget. I believe I have a solution on this, I'm waiting for @vecnehladny to have a look first.
etrahretep commented 4 years ago

Thanks! Very helpful! Some other issues: If a time specific event has a location on multiple lines, it also shows as whole-day event. (if i delete second and third line it shows as time specific.) Events spread over multiple days won't show, or undefined at second line. iCalbuddy's data shows it does, but not the widget. Very pleased with the widget's look and feel btw.

coolajami commented 4 years ago

Both problems have to do with how the icalbuddy manipulate the data export.

I believe my fork fixes the first problem with the location, but I cannot think any fix for the second issue for the time being, so inconsistencies with the presentation of all-day events that spread over multiple days will remain in the widget. I don't particularly bother by this, but if you like a way around the problem, you could set in your native MacOs calendar an all-day event for a single day only, and then copy-paste it over each day that the event take place (instead of making a single entry that extend to multiple days).

vecnehladny commented 4 years ago

Thanks! Very helpful! Some other issues: If a time specific event has a location on multiple lines, it also shows as whole-day event. (if i delete second and third line it shows as time specific.) Events spread over multiple days won't show, or undefined at second line. iCalbuddy's data shows it does, but not the widget. Very pleased with the widget's look and feel btw.

Main problem is that icalbuddy returns plain text. That means you cant recognize the context of returned values. If it would be JSON or XML, there would be no problem. I made that widget mainly for myself and for my needs it's sufficient. As i said in the README, feel free to fork it and play with it, maybe you'll have better luck with those problems. Appreciate your feedback!

coolajami commented 4 years ago

hi @vecnehladny I uploaded my fork file and I made a pull request. I would be happy to have a look and tell me what you think. It fixes the necessity to use the location for separating the events. @etrahretep you can download the file from the pull request if you like.

etrahretep commented 4 years ago

@vecnehladny Appreciate your work. Glad you posted the widget instead of keeping it to yourself ;-) @coolajami Fantastic! I translated it for my use and extended it for day after tomorrow (strange thing though: day after tomorrow in Dutch is "overmorgen" can't use that; seems to conflict with "morgen"(tomorrow). But "overmorge" works. strange: keep looking) But very happy so far.

Got my localisation for the clock also working with: command: "LC_TIME='nl_NL.UTF-8' date +\"#{format}\""

Schermafbeelding 2020-05-01 om 22 13 30
coolajami commented 4 years ago

@etrahretep that's actually brilliant for the localisation of the clock! For the problem with the "morgen" and the overmorgen" try to put spaces before and after the "morgen" where is mentioned in the script? it may stop it for recognising the "morgen" root in both words. it may utterless stupid however and I cannot test it in English.

etrahretep commented 4 years ago

That simple... space behind. THX!

Schermafbeelding 2020-05-02 om 00 11 33
coolajami commented 4 years ago

@etrahretep do you mind to share how you clone the morgen and the overmorgen so you can show 3 days in the calendar? That looks great!

etrahretep commented 4 years ago

@coolajami add dayaftertomorrow = [] clone and rename sections: (i edited back for english)

command: "/usr/local/bin/icalbuddy -n -po title,datetime,location -iep title,datetime,location eventsToday+2"


today = [] tomorrow = [] dayaftertomorrow = []

for i in [0...lines.length]
    if (lines[i].event.time.includes('today at'))
        lines[i].event.time = lines[i].event.time.replace("today at ","")
        #lines[i].event.name = lines[i].event.name.replace(/\([A-z]*\)/i, "")
        lines[i].event.time = lines[i].event.time.split(' - ')
        today.push(lines[i].event)
        continue

    else if(lines[i].event.time.includes('today')&&!lines[i].event.time.includes('at'))
        lines[i].event.time = lines[i].event.time.replace("today ","")
        lines[i].event.time = "whole - day"
        #lines[i].event.name = lines[i].event.name.replace(/\([A-z]*\)/i, "")
        lines[i].event.time = lines[i].event.time.split(' - ')
        today.push(lines[i].event)
        continue

    else if (lines[i].event.time.includes('tomorrow at'))
        lines[i].event.time = lines[i].event.time.replace("tomorrow at ","")
        #lines[i].event.name = lines[i].event.name.replace(/\([A-z]*\)/i, "")
        lines[i].event.time = lines[i].event.time.split(' - ')
        tomorrow.push(lines[i].event)
        continue

    else if(lines[i].event.time.includes('tomorrow')&&!lines[i].event.time.includes('at'))
        lines[i].event.time = lines[i].event.time.replace("tomorrow ","")
        lines[i].event.time = "whole - day"
        #lines[i].event.name = lines[i].event.name.replace(/\([A-z]*\)/i, "")
        lines[i].event.time = lines[i].event.time.split(' - ')
        tomorrow.push(lines[i].event)
        continue

    else if (lines[i].event.time.includes('day after tomorrow at'))
        lines[i].event.time = lines[i].event.time.replace("day after tomorrow at ","")
        #lines[i].event.name = lines[i].event.name.replace(/\([A-z]*\)/i, "")
        lines[i].event.time = lines[i].event.time.split(' - ')
        dayaftertomorrow.push(lines[i].event)
        continue

    else if(lines[i].event.time.includes('day after tomorrow')&&!lines[i].event.time.includes('at'))
        lines[i].event.time = lines[i].event.time.replace("day after tomorrow ","")
        lines[i].event.time = "whole - day"
        #lines[i].event.name = lines[i].event.name.replace(/\([A-z]*\)/i, "")
        lines[i].event.time = lines[i].event.time.split(' - ')
        dayaftertomorrow.push(lines[i].event)
        continue

inner += "<div class='mainBox'>" 
inner += "<div class='today eventBox'>"   
if today.length > 0
    inner += "<h2>Today</h2>"
    for i in [0...today.length]
        name = today[i].name

        calendarName = name.match(/\([a-zA-Z0-9\/\s]*?\)$/gmi)
        calendarName = calendarName[0].replace(/[\(-\)]+/gm,"")

        calendarColor = getCalendarColor(calendarName)

        name = name.replace(/\([a-zA-Z0-9\/\s]*?\)$/gmi, "")
        loc = today[i].location
        time = today[i].time
        inner += "<div class='event'><div class='leftBox' style=' border-color: #{calendarColor}'><div class='time'><div class='from'>"
        inner += time[0]
        inner += "</div><div class='to'>"
        inner += time[1]
        inner += "</div></div></div><div class='rightBox'><div class='title'>"
        inner += name
        inner += "</div><div class='location'>"
        inner += loc
        inner += "</div></div></div>"
else
    inner += "<div class='nothing'>Geen activiteiten vandaag</div>"

inner += "</div>"

inner += "<div class='tomorrow eventBox'>"
if tomorrow.length > 0
    inner += "<h2>Tomorrow</h2>"
    for i in [0...tomorrow.length]
        name = tomorrow[i].name

        calendarName = name.match(/\([a-zA-Z0-9\/\s]*?\)$/gmi)
        calendarName = calendarName[0].replace(/[\(-\)]+/gm,"")

        calendarColor = getCalendarColor(calendarName)

        name = name.replace(/\([a-zA-Z0-9\/\s]*?\)$/gmi, "")
        loc = tomorrow[i].location
        time = tomorrow[i].time
        inner += "<div class='event'><div class='leftBox' style=' border-color: #{calendarColor}'><div class='time'><div class='from'>"
        inner += time[0]
        inner += "</div><div class='to'>"
        inner += time[1]
        inner += "</div></div></div><div class='rightBox'><div class='title'>"
        inner += name
        inner += "</div><div class='location'>"
        inner += loc
        inner += "</div></div></div>"
else
    inner += "<div class='nothing'>Geen activiteiten morgen</div>"

inner += "</div>"
inner += "<div class='dayaftertomorrow eventBox'>"

if dayaftertomorrow.length > 0
    inner += "<h2>Day after tomorrow </h2>"
    for i in [0...dayaftertomorrow.length]
        name = dayaftertomorrow[i].name

        calendarName = name.match(/\([a-zA-Z0-9\/\s]*?\)$/gmi)
        calendarName = calendarName[0].replace(/[\(-\)]+/gm,"")

        calendarColor = getCalendarColor(calendarName)

        name = name.replace(/\([a-zA-Z0-9\/\s]*?\)$/gmi, "")
        loc = dayaftertomorrow[i].location
        time = dayaftertomorrow[i].time
        inner += "<div class='event'><div class='leftBox' style=' border-color: #{calendarColor}'><div class='time'><div class='from'>"
        inner += time[0]
        inner += "</div><div class='to'>"
        inner += time[1]
        inner += "</div></div></div><div class='rightBox'><div class='title'>"
        inner += name
        inner += "</div><div class='location'>"
        inner += loc
        inner += "</div></div></div>"
else
    inner += "<div class='nothing'>Geen activiteiten overmorgen</div>"

inner += "</div>"
inner += "</div>"

$(calendar).html(inner)
coolajami commented 4 years ago

@etrahretep thanks, appreciated!

etrahretep commented 4 years ago

Other question: Birthday's show incomplete. Without birthday and age (%i) What am i missing?

coolajami commented 4 years ago

Other question: Birthday's show incomplete. Without birthday and age (%i) What am i missing?

they appear correctly to me :/ are you using the contact birthdays I presume.

etrahretep commented 4 years ago

Yes, using the Apple contact Birthdays (is there another way with iCalbuddy?) "someonesBirthday" isn't picking up anything.. Only the names show. Tried with and without ~/.icalBuddyLocalization.plist and changing language.. No dice.

etrahretep commented 4 years ago

Spotted something else. "day after tomorrow" whole day events appear "tomorrow" and stay/change back to "tomorrow" when passing 00.00 h. Can't seem to find this anomaly in the script.

coolajami commented 4 years ago

Spotted something else. "day after tomorrow" whole day events appear "tomorrow" and stay/change back to "tomorrow" when passing 00.00 h. Can't seem to find this anomaly in the script.

@etrahretep For the all-day events in the day after tomorrow section, I amend the script that pulls the events as below and did the trick.

Birthdays are pulled correctly in my case, I'm not sure why it is doing this. Any chance that the calendar pulls birthdays from other sources like contacts that sync with Facebook? I'm not using this, but I believe that you can add the Facebook contacts in the native macOS Contacts app, and in that case, I was thinking that if there is only a declaration of day/month and not the year in the birthdays (something you see often in facebook lists) that it may not pull the data correctly. Screenshot 2020-05-04 at 09 41 37

etrahretep commented 4 years ago

Facebook stopped sharing events and birthdays a while ago. Using only native birthday's trough adressbook. Strange that i cab't get it to work. Tried the original widget without localisation and switched to English om my MBP and iMac. I'm using the latest Catalina beta, maybe that's the culprit.

coolajami commented 4 years ago

I didn't now that about Facebook,thanks! I run a few tests, changing date format and localisations, and couldn't replicate the problem. possible the beta causing it.

etrahretep commented 4 years ago

Thanks again for testing. Very helpful.

Schermafbeelding 2020-05-04 om 18 25 41

I'll try tonight on Mojave, see what it does...

etrahretep commented 4 years ago

@coolajami Found it! A reset of TCC did the trick.

etrahretep commented 4 years ago

@vecnehladny @coolajami I'd like the calwidget to represent the iPhone as close as possible. Is it possible to show remaining time (as in screenshot; over x uur)? Wouldn't know where to begin really... IMG_0015

etrahretep commented 4 years ago

@vecnehladny @coolajami And another question: if i make the height of the cal widget dynamic, is there a way the weather widget follows that height?

coolajami commented 4 years ago

@vecnehladny @coolajami And another question: if i make the height of the cal widget dynamic, is there a way the weather widget follows that height?

@etrahretep for the time remaining, potential that could be done, but I would not have the knowledge to do it myself. Icalbuddy doesn't help much because does not export the data in JSON so the options to manipulate the data are very limited.

For the dynamic range, I don't think is possible because of the two widget act independently within ubersicht. It may be a way to combine the CSS outcomes within a single widget.

etrahretep commented 4 years ago

Found a way. Kind of a trick. it's a widget which calls an applescript and displays time and event. I managed to align the time only to the second line (but it is static on top), but really looking for a way to incorporate it in the cal widget. Tried for hours but can't find it. Willing to take a shot at it?

Schermafbeelding 2020-05-09 om 21 26 41
etrahretep commented 4 years ago

And another question... ;-)

I have multiline locationdata which i show like this:

Schermafbeelding 2020-05-09 om 22 03 10

But how do i suppress the undefined entries in non location events?

Schermafbeelding 2020-05-09 om 21 57 22
coolajami commented 4 years ago

@etrahretep for the suppression of the undefined lines in the events with no location, you need to add an else statement like below. For some reason, if you have events with one line in the location, the "undefined" statement appears again in the 3rd line only, I'm not sure why. If you reduce the lines from 3 to 2, then the problem disappears.

Screenshot 2020-05-11 at 12 17 01

For the remaining time, the challenge is to pull and translate the hour text string from icalbuddy to a time object that you'll able to apply the script you found (I suppose you talk about the countdown widget). I don't think it is impossible but definitely needs some time spending on this. I'll give it a go when I got some time but it may be way above my knowledge in java.

etrahretep commented 4 years ago

Thanks again lifesaver! Can i send the script and shortened widget to try? (and where to) Actually it is part of sidebar widget https://github.com/Pe8er/Sidebar.Widget Time until next calendar event (uses icalbuddy, hides dynamically)

coolajami commented 4 years ago

@etrahretep yes, happy to have a look, not promising results though, I'll download the sidebar widget and I'll play around with it. I'm still browsing StackOverflow heavily for finding answers. You can upload the script in your repository and I could download it from there so we can also co-operate on this. otherwise, email me to coolajami@hotmail.com