In the time package, when formatting a time.Time variable, the output will use the English names for weeks and months as defined in unexported []string slices.
How to localize the string, using a different language (hopefully still using Format())?
Example:
fmt.Println(time.Now().Format("Mon 2 January 2006"))
Output:
Tue 28 January 2014
Desired output:
Tis 28 Januari 2014
Playground
As you can see in time package sourcecode that values are hardcoded in source. So, basically, Go doesn't support i18n right now. i18n is on Go roadmap, its even mentioned in the faq, but there were no comments on that topic recently.
Meanwhile, you could try to use Monday package:
// Change LocaleEnUS to the locale you want to use for translation
monday.Format(time.Now(), "Mon 2 January 2006", monday.LocaleEnUS)
Related
what I want to get
how make a localisation with NSPredicateEditorRowTemplate
it is not well documented
it was a total pain to figure out.
all is written programmatically
I would like a French, Italian version etc.
https://github.com/thierryH91200/THPredicateEditorSwift
Localizing an NSPredicateEditor is a bit more involved than usual localisation.
First, you'll need to have NSLocalizedString() calls in your code somewhere so that genstrings is able to find them.
Secondly, the key needs to follow a special format that will instruct genstrings to produce all combinations of a given row:
NSLocalizedStringFromTable(#"%[Any, All, None]# of the following are true", #"Predicate", #"localize the compound row template")
NSLocalizedStringFromTable(#"%[property]# %[is, is not, contains, begins with, ends with, like, matches]# %#", #"Predicate", #"localize the string row template")
NSLocalizedStringFromTable(#"%[birthMonth]# %[is, is not]# %[January, February, March, April, May, June, July, August, September, October, November, December]#", #"Predicate", #"localize the selection row template")
In the example above genstrings will look at the options between brackets and generate a localisation string for all combinations in the Predicate.strings file.
Finally, you must let your NSPredicateEditor instance know which strings file to use by setting the formattingStringsFilename property.
See this blog post for more information.
the blog is a few years old.
xcode has improved over the years.
the question is duplicate but the answers may be different a few years later.
the answer is simple. it is the localization of the xib file and it works perfectly
I am trying to use Mailchimp.com's API 3.0 to add people from a PHP web server, but my datetime values for "timestamp_signup"and "timestamp_opt" are being rejected on insert subscriber.
According to this page :
https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/
the format of timestamp_signup and timestamp_opt is ISO 8601 format and both are writeable.
But all the versions I have tried have been rejected:
"2018-10-19T13:50:37+01:00"
"2018-10-19T13:50:37"
"2018-10-19T13:50"
"2018-10-19"
Many thanks
Ian
What is the correct format?
Great find Ian, that seems to be a new issue within the MailChimp API that occurred first with us around a week ago, but it seems to also not happen always.
I contacted the MailChimp Support and they confirmed it seems to be a problem on their end and that they will look into it.
For now I can confirm that your workaround (YYYY-MM-DD HH:MM:SS) works fine but it is not what the MailChimp API states and should definitely be fixed by them.
The format to use is YYYY-MM-DD HH:MM:SS
Not ISO 8601 which is YYYY-MM-DDTHH:MM:SS+HH:MM
Mailchimp.com's software generated correct ISO8601 dates when it sends datetimes back. However it requires the "T" to be a space, and will reject a date that includes the timezone (the +HH:MM on the end).
This is contrary to my reading of the standard.
#Ian is correct. The right format is not ISO 8601 but the classic one:
YYYY-MM-DD HH:MM:ss
Be careful if you're using JS/NodeJS with momentJS for instance. The right format is the following:
moment().format("YYYY-MM-DD HH:MM:ss")
The seconds are in lower case. Otherwise, you will have the fractional value which results in an error on the Mailchimp side.
I've been trying to figure this out for a while. Is there a way to set up a service that would parse a Note and create calendar events based on each line from that Note?
For example, say that the contents of my note are as follows:
December 1 9:00AM - 5:00PM
December 2 9:00AM - 5:00PM
December 3 11:30AM - 8:00PM
Is anyone familiar with how to parse this? I'd like to set up a service that would take those dates, and those hours and create calendar events with a default name (ex. "Work"). I'm familiar with how to do it in programming languages like Python or Swift, but I'm still new to scripting.
Any help would be appreciated. Thanks!
I have posted two posts to my blog in the past two days. As you can see, both are dated Nov 1, 2017. I correctly named the files with their respective dates as you can see in the github repofor this blog. What is going on here? Why do the posts show the wrong date?
You have in the YML the following date:
2017-10-20 0800:00:00 -0600
This should be:
2017-10-20 08:00:00 -0600
(The first colon is preceded by too many zero's)
This might be a simple one but I can't seem to find an easy solution. I need to format a date as a string to be represented in a full form for a locale. Example:
May 28, 2011 (for US locale)
_strftime_l(_T("%#x")) can do a similar thing but it adds a weekday up front, that I don't need.
GetDateFormat and GetTimeFormat (or the Ex versions for Vista and up).