Following on from an issue with the date format in Easy Copy since Firefox 29, I've found an easy way to get the date or time in the long or short date formats from JavaScript in a Firefox extension.
Easy Copy used to use Date.toLocaleDateString() to get the long date but this method stopped working correctly in Firefox 29 and just returned the date in a default format. The changes were made to enable the ECMAScript internationalization API in Firefox.
In this post, I'll explain how to get the long date and short date formats consistently.
The blog for Easy Copy, the Firefox extension that makes it easy to copy stuff on the web.
Showing posts with label extension development. Show all posts
Showing posts with label extension development. Show all posts
Monday, 26 May 2014
Tuesday, 22 April 2014
Handling characters from any language in preferences used by Firefox extensions
Since Easy Copy allows you to enter any template you want to, you should be able to enter characters in your own language. So whether you use Russian, Japanese or Chinese characters, these should be displayed, copied, stored and retrieved correctly.
Easy Copy stores and retrieves template preferences manually and the Firefox preference tutorials don't mention that you have to handle these characters specially. Even if you use <prefpane> and <preferences> to store preferences, you still need to read them back in a special way.
Easy Copy initially didn't handle this correctly so users' preferences were getting garbled (fixed in v2.0.1). For example, the following template uses the Russian word шеллы (apparently means shells):
Easy Copy stores and retrieves template preferences manually and the Firefox preference tutorials don't mention that you have to handle these characters specially. Even if you use <prefpane> and <preferences> to store preferences, you still need to read them back in a special way.
Easy Copy initially didn't handle this correctly so users' preferences were getting garbled (fixed in v2.0.1). For example, the following template uses the Russian word шеллы (apparently means shells):
URL: %url% and шеллы
would end up looking something like:URL: %url% and H5;;K
Not quite what you expected. Below I'll describe an easy trick that will allow you to handle all characters correctly.
Subscribe to:
Posts (Atom)