umbraco-community / Our.Umbraco.OpeningHours

An Umbraco property editor for handling opening hours
MIT License
9 stars 13 forks source link

Add custom language file #26

Closed wiedikerli closed 7 years ago

wiedikerli commented 7 years ago

I've added de-CH.xml to lang. Do I have to configure something elsewhere?

abjerner commented 7 years ago

@ninjaonsafari adding the file to the lang folder should be sufficient. If you can make a pull request, I'd be happy to merge that into the project ;)

wiedikerli commented 7 years ago

@abjerner is this file only used in the backend?

abjerner commented 7 years ago

@ninjaonsafari Yup

abjerner commented 7 years ago

Closing the issue here as #27 now has been merged.

wiedikerli commented 7 years ago

@abjerner could it be possible that the label gets filled with the values from the language files on basis of the current culture?

abjerner commented 7 years ago

@ninjaonsafari The GetUpcomingDays method will return an array of OpeningHoursDay, which has a WeekDayName property with the localized name of the day (according to the current culture and C#'s own localization). There is also a WeekDayNameFirstCharToUpper property where the first character is automatically converted to uppercase because not all languages start their day names with an uppercase character - eg. Tuesday is tirsdag in Danish.

<table>
    @foreach (OpeningHoursDay day in openingHours.GetUpcomingDays(15)) {
        <tr>
            <td>@day.WeekDayName</td>
            <td>@day.WeekDayNameFirstCharToUpper</td>
            <td>@day.Label</td>
        </tr>
    }
</table>

If you're instead just using openingHours.Weekdays.Values, which returns a collection of OpeningHoursWeekdayItem, there isn't a similar property for the localized name as the items are not coupled with a specific date. I will see if I can do something else to expose the local day name here as well ;)

abjerner commented 7 years ago

With the release I've just pushed, OpeningHoursWeekdayItem now has the WeekDayName and WeekDayNameFirstCharToUpper properties as well ;)