Skip to content
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

Localized short day name #1

Closed
intik opened this issue Dec 15, 2015 · 2 comments
Closed

Localized short day name #1

intik opened this issue Dec 15, 2015 · 2 comments

Comments

@intik
Copy link

intik commented Dec 15, 2015

Hi,

instead of hardcoded short day names, you can use dynamically loaded localized names. In WeekCalendar.java change String[] days = {...} to something like this:

// Get localized short names for days. Index 0 = empty string (always). Rest are name days starting with sunday
String[] weekDays = DateFormatSymbols.getInstance().getShortWeekdays();
// Convert into List
List<String> listDays = new ArrayList<>(Arrays.asList(weekDays));
// Remove empty string
listDays.remove(0);
// Remove Sunday from beginning
String sunday = listDays.remove(0);
// Add Sunday to the end of array
listDays.add(sunday);

// convert back into String[], or just use listDays
String[] days = new String[listDays.size()];
listDays.toArray(days);

On my Locale this will get array, where day names are two characters long, which is ok, they will fit in WeekView. But for example in English locale this will return day names three characters long and it's too long. So day names can be shortened like (before converting to String[]):

for (int i = 0; i < listDays.size(); i++) {
    listDays.set(i, listDays.get(i).substring(0, 1));
}

Hope this will help, keep up the good work, this View was exactly what I was looking for!

@nomanr
Copy link
Owner

nomanr commented Dec 15, 2015

Hello,
I am glad that this view helped you.
Yeah I had a few things in mind, and the day names are also in todo list.
I will add options for both 1 char and 3 char days and the day names will be according to Locale.

@nomanr
Copy link
Owner

nomanr commented Dec 16, 2015

User version 1.0.3, this issue has be resolved and also you can use dayNameLength xml attribute to get single letter of 3 letter long day name.
Thanks for the tip, it Helped!

@nomanr nomanr closed this as completed Dec 16, 2015
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

No branches or pull requests

2 participants