When saving a Spanish date string value into an Archetypes DateTimeField, the field ends up with a None value. I've read through the DateTimeField code and there is no locale code there at all. I am sure that this, like most things, has already been done somewhere in Plone, and I would like to know where, please.
If it hasn't yet been done, then I would appreciate any comments you might have about my plan. I have collected some information from Google and SO, and this is what I came up with:
1) I will subclass the Archetypes/Field.py/DateTimeField() in my own source.
2) I will use ##plone_portal_state/language() to get the current language code.
3) Then set locale, using locale.setlocale(local.LC_TIME, LANG_CODE).
4) I will convert the string value to a python datetime object.
5) I will use dt2DT to convert the value to zope DateTime.
6) I will then write the value.
This is a silly plan, but it is what I know, and I would love some clues.
Thank you!
I have similar problem, but what I want is to display local time such as Jan 01, 2012 in French in Spanish locale, however doing research I found out that locale.setlocale is not thread safe on most of the systems, so it's not a good idea to keep setting/unsetting it because it will probably set that particular locale for everyone using the site.
You still can install required locales for the selected languages, in Debian you can do this with:
#aptitude install locales
then
#dpkg-reconfigure locales
Select all the locale languages you need and the system would have them. There should be a way of translating month name formats, but I haven't found it yet.
Sources:
Plone discussion -- http://plone.293351.n2.nabble.com/Plone-strftime-and-locales-question-td6602394.html
Python locale documentation page, scroll down to locale.setlocale -- http://docs.python.org/library/locale.html
EDIT: Also instead of locale.setlocale you might want to use babel package, as it appears to be thread-safe, I'm currently investigating that possibility for my own project.
Stack Overflow discussion -- https://stackoverflow.com/a/225106/86294
Babel on Pypi -- http://pypi.python.org/pypi/Babel
Related
I want to evaluate some statistics of my Plone installation and first of all I wanted to know how the total number of Pages of my Plone changing over time.
I had a look at the existing Plone statistics addons. Unfortunately there are none for Plone 5.0. I got quintagroup.analytics running. This addon has interesting metrics, but does not help me seeing the development over time.
So i started programming myself. In order to get the current number of Pages I plan to use a catalog query like this:
catalog = getToolByName(self.context, 'portal_catalog')
catalog.searchResults({'portal_type': 'Document'})
return len(results)
The python script should be run by a cron job every hour and write the result to a log file for me to evaluate later.
My question for you is: Are there any simpler solutions I did not see? Would my solution work? Do you see any conceptual errors in that?
I wonder that there are not more questions like that on the internet. Are people not that much interested in the metrics of their CMS, or did I ignore an obvious simple solution for that?
At the moment the solution does not yet ron, because of my inexperience with the structure of the plone addons, especially calling a python script, but I am working on that.
If you go to "Site Setup" -> "Dexterity Content Types" you can see how many objects of a certain content type currently exist in your site, e.g.:
http://plonedemo.kitconcept.com/##dexterity-types
There is no out-of-the box way to gather or present those statistics over time though.
You could use the data the catalog itself provides:
portal_catalog.Indexes['portal_type'].uniqueValues(withLengths=True)
gives you counts for all types, as a list of (name, count) tuples:
(('CaptchaField', 2), ('Collection', 2), ('Document', 676), ...
I've not double-checked if this avoids searching and len-ing the results, but it's easier than catalog searches if you think you might be interested in more than one type.
(I've only checked this on 4.3.x/Archetypes, but I see no reason it would not work with 5.x/Dexterity as long as it still uses portal_catalog.)
I'd like R to show me debug messages in english instead that in my locale (Italian). Having messages in italians makes it difficult to look on the internet for help on debugging. Not to mention that sometimes translations are sloppy at least.
How can revert R to use only the original version of messages and not to translate them?
thanks!
You want to set the "LANGUAGE" environment variable (see relevant documentation):
Sys.setenv(LANGUAGE='en')
To do this, though, you need to have message translations installed (which I believe are optional on at least some platforms).
Alfresco allows uploading newer versions of documents in the repository and also keeps track of the version history, it seems. However, I could not find any way to compare or diff a document with its prior versions.
Is this possible? are there any good external plugins or tools for this?
I assume you think of something similiar to the good old Unix diff tool which basically compares text files and can show the result in a human readable form.
The general equivalent situation in alfresco is far more complicated. You have an arbitrary amount of properties of different type. The text file you might think of just happens to have character bytes in cm:content.
So to answer your question : I don't know of any extension providing a general diff between versions, but it should not be two hard rolling your own for text files other simple special comparisons. In the former case you might want to have a look at Java library for free-text diff for libraries providing the base functionality.
Looking for the same functionality and found this Alfresco addon
http://code.google.com/p/versions-difference-alfresco-plug-in/
I'm looking for a way to include a full blown English dictionary in an iPhone app (a word game), the database must be able to include all conjugation possibilities for verbs, must include singular and plural spellings. So my app can query the database to check if the spelling is correct.
Is there a free or commercial database that would include those data?
You can use UITextChecker for spell-checking.
Regarding a dictionary, when I built an iOS dictionary library sometime ago (www.lexicontext.com) I used WordNet. WordNet contains a lot of interesting semantic info ...
NSSpellChecker is your easiest option, but it might be more complete to use the online Scrabble official dictionary as well and check it against both (only one match required.)
You could do a web-service request using http://www.hasbro.com/scrabble/en_US/search.cfm
http://www.a2zwordfinder.com/cgi-bin/scrabble.cgi?Letters=&Pattern=______&MatchType=Exactly&MinLetters=3&SortBy=Alpha&SearchType=Scrabble
Change min letters to get different results
The best place to find a database for a spell-checker is probably a free text processing application. So, I'd try with Open Office version of Word. Download it, install it and simply find the dictionary file.
Open Office is licensed under LGPL, so it should be fine, just check if the licence covers the data as well (i.e. the dictionary file).
Maybe this English corpus helps: http://www.wordfrequency.info/free.asp
i have an English Drupal installation but the frontend needs to be dutch. Now i asked a few weeks ago if it's possible to install a different backend and frontend language but this seems to be difficult. Now i only have one small message that isn't translated yet in the frontend and this is the required field error message (... field is required). How can i edit this translations? The may be an easy not so clean solution.
If you want an english backend and Dutch frontend you should use admin language that should fix that problem for you. In regards to translating the field required, that should be simple enough. It use a placeholder, so you might need to look for something like
#field is required
Drupal use this system when it use the same string with a dynamic value so you only need to translate it once and not for every combo.
thanks, for the admin_language module, but i found how to do this simple translation. You can override the translations using 'String overrides' ins settings.php