I've start my first dev yesterday and congratulation : your framework is really easy to use !
I've some questions about localization and internationalization :
1 - My plugin doesn't load when I used French special characters like "éè" in AddPrefixHandler or MediaContainer (I want to use "Allociné"). Is this a restriction of the current framework or do I have to add special code or function in python to use this type of character in strings
2 - Is their a way to have localizable preferences for a plugin. I don't find how to process with the "DefaultPrefs.json" file ?
I've to add the encoding attribute to avoid an error like "UnicodeDecodeError: 'utf8' codec can't decode bytes in position 446-448: invalid data"
then
for c in fluxXML.xpath("//item"):<br />
Log("c %s" % (lxml.etree.tostring(c, pretty_print=True)))<br />
title = c.find('title').text.encode("utf-8")<br />
Log("title %s" % (title))<br />
thumb = c.find('enclosure').get('url')<br />
Log("thumb %s" % (thumb))<br />
url = c.find('link').text.encode("utf-8")<br />
Log("url %s" % (url))<br />
dir.Append(VideoItem(url, title=title, thumb=thumb))
The first Log show the data from one and I find in it : "Toy Story 3 - Teaser 1 (Anglais sous-titr& #195;& #169;)" (I've add a space between & and # to avoid a convertion in the post editor)
Notice the utf8 code for "é" character
Last when I return the dir object I've the following error :
"UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 41: ordinal not in range(128)"
Sorry I do not have an answer for you but I do run in exactly the same problem when trying to parse XML files from the france2 website. I poked around a bit and the only things I could find was to do an decode(“Latin-1”).encode(“utf-8”) and that seemed to get me a bit further but eventually the error “cannot decode byte 0xc3” creeps up. Just sharing your pain …
I18N and encodings is hard in general, and I’m not sure that Python isn’t making it a bit harder than it needs to be.
In AddPrefixHandler or MediaContainer, do this: “Allociné”.decode(‘utf-8’) and put this at the top of your file:
# -*- coding: utf-8 -*-
That should solve that specific problem. The decode/encode tricks of the last reply can help too, as can specifying
errors='ignore' after the encoding=...
The fight with character encodings is going on behind the scenes, hopefully we should be able to make the framework handle things more gracefully :)
With regard to localized preferences, the label you specify in DefaultPrefs.json gets passed to the Locale module before being returned to Plex - if it's a vaild key, the localized string will be returned from the current strings file (e.g. Contents/Strings/fr.json). If not, the provided text will be used.
1 - The Elan’s solution works to have an accent in the Plugin title.
2 - I succeed in using unicode object to avoid Plugin crash. Complicated to explain, you’ll can see the solution in the “Allociné” plugin sources when it will be release. To give some clues, Plex framework seems to manage well unicode string decoded in utf-8 but don’t forget to encode your unicode string before using it in Logs.
3 - The preference seems to be localizable. I haven’t try yet.
Now I just have to find why my video stream doesn’t play, and you’ll have another french plugin.
I’ve start a list on the French forum with French speaking plugins. I’ve identified English plugins which are giving access to French contents : YouTube and Pisacca. I’ve already done the translation of the string file for Picassa. YouTube doesn’t seem to use this type of file. Is it planned ?
I don't succed in making this to work. In the "Picasa web Album " plugin I add this in the fr.json file :
[codebox]// Preferences
"Google/Picasa Username" : "Identifiant Google/Picasa",
"Google/Picasa Password" : "Mot de passe Google/Picasa",
"Show my private albums" : "Afficher mes albums privés",
"Show summary information on photographs" : "Afficher les résumés des photographes"[/codebox]