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

Length is the short for non-English localizations #6

Open
shmidt opened this issue Feb 25, 2012 · 4 comments
Open

Length is the short for non-English localizations #6

shmidt opened this issue Feb 25, 2012 · 4 comments

Comments

@shmidt
Copy link

shmidt commented Feb 25, 2012

In a few non-English localizations time length is much longer than US but the length of TimeScroller is fixed now, so in other localization text goes out of black field.

@andrewroycarter
Copy link
Owner

I'll look into this!
I'm not super informed when it comes to time localization, so if someone wants to contribute on this one quicker then me feel free!

@honkmaster
Copy link

Im doing it this way.

if (dateComponents.year == todayComponents.year && dateComponents.month == todayComponents.month && dateComponents.day == todayComponents.day) {

    timeLabelFrame = CGRectMake(30.0f, 4.0f, 100.0f, 20.0f);
    dateLabelString = @"";
    dateLabelAlpha = 0.0f;

} else if ((dateComponents.year == todayComponents.year) && (dateComponents.month == todayComponents.month) && (dateComponents.day == todayComponents.day - 1)) {

    timeLabelFrame = CGRectMake(30.0f, 4.0f, 100.0f, 10.0f);
    dateLabelString = NSLocalizedString(@"Yesterday", @"Yesterday");
    dateLabelAlpha = 1.0f;

} else if ((dateComponents.year == todayComponents.year) && (dateComponents.weekOfYear == todayComponents.weekOfYear)) {

    timeLabelFrame = CGRectMake(30.0f, 4.0f, 100.0f, 10.0f);                
    dateLabelString = [self.dayOfWeekDateFormatter stringFromDate:date];
    dateLabelAlpha = 1.0f;

} else if (dateComponents.year == todayComponents.year) {

    timeLabelFrame = CGRectMake(30.0f, 4.0f, 100.0f, 10.0f);

    dateLabelString = [self.monthDayDateFormatter stringFromDate:date];
    dateLabelAlpha = 1.0f;

} else {

    timeLabelFrame = CGRectMake(30.0f, 4.0f, 100.0f, 10.0f);
    dateLabelString = [self.monthDayYearDateFormatter stringFromDate:date];
    dateLabelAlpha = 1.0f;

} 

CGFloat timeWidth = [timeLabelString sizeWithFont:_timeLabel.font].width;
CGFloat dateWidth = [dateLabelString sizeWithFont:_dateLabel.font].width;
CGFloat width = ( timeWidth > dateWidth ? timeWidth : dateWidth) + 40.0f;
backgroundFrame = CGRectMake(CGRectGetWidth(self.frame) - width, 0.0f, width, CGRectGetHeight(self.frame));

@andrewroycarter
Copy link
Owner

@honkmaster It's been a while, but if you'd like to submit those changes as a pull request I'd be happy to check them out and merge them in! I've recently changed up the project a bit, but it's nothing that shouldn't take more than a few minutes to sync up with!

@honkmaster
Copy link

I will see what i can do and submit a pull request in the next days,

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

3 participants