yannickl / YLMoment

Parsing, validating, manipulating, and formatting dates easily in Objective-C (API inspired by moment.js)

Home Page:http://yannickl.github.io/YLMoment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Localization problem time string change locale without config.

giver opened this issue · comments

Before update to 0.3.0, I think my locale default with 'en' but after update to 0.3.0 my locale was automatic change to 'de' (I notice by the string it was produced). I don't know why. Because I never touch the localization setting in my app before.

Indeed, it is weird. I fixed some issues with the localized strings in the last version (0.4.1). Can you try with this version?
Otherwise, have you tried to print the [[NSBundle mainBundle] preferredLocalizations]?

@yannickl Sorry my fault, I tell you the wrong version. Currently, I use YLMoment (0.4.0). I install it via Cocoapods

Before:
YLMoment (0.3.0) -- No problem
After:
YLMoment (0.4.0) -- Problem here

[[NSBundle mainBundle] preferredLocalizations] // --> en

@giver Are you using Cocoapods or have you installed the library manually?

What happens if you manually set the locale? E.g. [[YLMoment proxy] setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US"]];?

@yannickl

Not working

[[YLMoment proxy] setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US"]];
YLMoment *moment = [YLMoment momentWithDateAsString:time format:@"yyyy-MM-dd'T'HH:mm:ssZZZZZ"];
_timeLabel.text = [moment fromNow];

Working code (I must specific locale)

YLMoment *moment = [YLMoment momentWithDateAsString:time format:@"yyyy-MM-dd'T'HH:mm:ssZZZZZ" localeIdentifier:@"en_US"];

@giver I'll do some test tonight to see if I can find the prob.

@giver I updated the code. Can you tell me if everything is ok now please?

@yannickl It doesn't work. I'm not sure if there is some code or environment configuration that make the things mess up.

@giver Very strange, the test on my local configuration works. Is it possible to have a sample project which reproduce the issue?