feat: enhance city localization and timezone handling
- Update localized_name method to provide a default value for missing translations - Modify timezone display in city show view to show a message when the timezone is undefined These changes improve user experience by ensuring that the city localization falls back to the city name itself if a translation is not found, and they handle potentially missing timezone data more gracefully.
This commit is contained in:
parent
f0f94de528
commit
c332230709
@ -84,7 +84,7 @@ class City < ApplicationRecord
|
||||
end
|
||||
|
||||
def localized_name
|
||||
I18n.t("cities.#{name.parameterize.underscore}")
|
||||
I18n.t("cities.#{name.parameterize.underscore}", default: name)
|
||||
end
|
||||
|
||||
def full_name
|
||||
|
@ -35,7 +35,7 @@
|
||||
<%= @city.country.name %>, <%= @city.region %>
|
||||
</div>
|
||||
<div class="badge badge-lg badge-secondary gap-2">
|
||||
<%= Time.current.in_time_zone(@city.timezone).strftime("%Y-%m-%d %H:%M") %>
|
||||
<%= @city.timezone.present? ? Time.current.in_time_zone(@city.timezone).strftime("%Y-%m-%d %H:%M") : "Timezone undefined" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user