Skip to content

Commit

Permalink
chore: improved locales
Browse files Browse the repository at this point in the history
  • Loading branch information
SilasPeters committed Dec 24, 2024
1 parent b48dff9 commit 66631d4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
18 changes: 12 additions & 6 deletions app/models/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -390,17 +390,21 @@ def activity_url
return "https://koala.svsticky.nl/activities/#{ id }"
end

# The description of the activity in the specified locale
def description_localised(locale)
return locale == :nl ? description_nl : description_en
end

# This generates an URL representing a calendar activity template, filled with data from the koala activity
def google_event(loc = nil)
def google_event(locale = nil)
return nil if start.nil? || self.end.nil?

loc = I18n.locale if loc.nil?
disclaimer = "[#{ I18n.t('activerecord.attributes.activity.disclaimer') }]"
description = "#{ activity_url }\n\n#{ description_localised(loc) }\n\n#{ disclaimer }"
locale = I18n.locale if locale.nil?

disclaimer = "[#{ I18n.t('activerecord.attributes.activity.disclaimer', deep_interpolation: true,
datetime: DateTime.current.utc.to_s) }]"
description = "#{ activity_url }\n\n#{ description_localised(locale) }\n\n#{ disclaimer }"

uri_name = URI.encode_www_form_component(name)
uri_description = URI.encode_www_form_component(description)
uri_location = URI.encode_www_form_component(location)
Expand Down Expand Up @@ -442,7 +446,7 @@ def gen_time_string(loc)
return fmt_dt.call(start_date) + fmt_tm.call(start_time) + edt
end

# Converts a sticky activity to an iCalendar event
# Converts a Sticky activity to an iCalendar event
def to_calendar_event(locale)
event = Icalendar::Event.new
event.uid = id.to_s
Expand All @@ -458,7 +462,9 @@ def to_calendar_event(locale)
end

event.summary = name
event.description = description_localised(locale)
event.description = "#{ activity_url }\r\n\r\n\
#{ description_localised(locale) }\r\n\r\n\
Last synced on: #{ DateTime.current.utc }"
event.location = location
return event
end
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ en:
description: Description
description_en: English description
description_nl: Dutch description
disclaimer: Data on this activity may be outdated, as it was added as a one-time copy of the information given at that time. Up-to-date info can be found on Koala.
disclaimer: Data about this activity has been added as a one-time copy from what was known on %{datetime}, and as such could be outdated.
end_date: Enddate
end_time: Endtime
google_event: Copy once to calendar
Expand Down
2 changes: 1 addition & 1 deletion config/locales/members.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ en:
calendar:
confirm_understand_icalendar:
confirm: I understand
text: Koala will maintain the icalendar feed you just copied, at all times. However, koala is only aware of activities for which you are enrolled through koala, and not through some other platform (like Pretix or a Google form). Remember to add those activities to your calendar manually.
text: Koala will maintain the icalendar feed you just copied to your clipboard, at all times. However, koala is only aware of activities for which you are enrolled through koala, and not through some other platform (like Pretix or a Google form). Remember to add those activities to your calendar manually.
title: Warning
error:
edit: Could not edit!
Expand Down
2 changes: 1 addition & 1 deletion config/locales/members.nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ nl:
calendar:
confirm_understand_icalendar:
confirm: Ik begrijp het
text: Koala zal de icalendar feed die je zojuist hebt gekopieerd te allen tijde bijwerken. Echter, is koala alleen op de hoogte van activiteiten waarvoor je je via Koala hebt ingeschreven, en niet via een ander platform (zoals Pretix of een Google Form). Vergeet niet om die activiteiten handmatig aan je agenda toe te voegen.
text: Koala zal de icalendar feed die je zojuist hebt gekopieerd naar je klembord ten aller tijde bijwerken. Echter, is koala alleen op de hoogte van activiteiten waarvoor je je via Koala hebt ingeschreven, en niet via een ander platform (zoals Pretix of een Google Form). Vergeet niet om die activiteiten handmatig aan je agenda toe te voegen.
title: Waarschuwing
error:
edit: Kon niet bijwerken!
Expand Down
2 changes: 1 addition & 1 deletion config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ nl:
description: Beschrijving
description_en: Engelse beschrijving
description_nl: Nederlandse beschrijving
disclaimer: Gegevens in deze afspraak kunnen outdated zijn, omdat deze waren toegevoegd als een eenmalig kopie van wat toen bekend was. Up-to-date informatie staat op Koala.
disclaimer: Gegevens over deze activiteit zijn toegevoegd als een eenmalig kopie van wat bekend was op %{datetime}, en kunnen dus verouderd zijn.
end_date: Einddatum
end_time: Eindtijd
google_event: Kopiëer eenmalig naar agenda
Expand Down

0 comments on commit 66631d4

Please sign in to comment.