• 1
  • 2(current)
  • 3
  • 4
  • 5
  • 33
[XBOX] T3CH Upgrader (Python Script)
#16
jmarshall: potential risk there, but then again, whatever you do with bootstuff might break.. wont say its safe to do anything, but agree it would be made optional.


BBB: think you need to change the fileformat to UTF-8 for it to work..
Reply
#17
blitten: the XML file does already have encoding="utf-8" Is that what you meant ?


In the language.py I've added this function:

Code:
def unicodeToAscii(txt, charset='utf8'):
    print "unicodeToAscii()"
    try:
        newtxt = txt.decode(charset)
        newtxt = unicodedata.normalize('NFKD', newtxt).encode('ASCII','replace')
        return newtxt
    except:
        print "unicodeToAscii() except"
        traceback.print_exc()
        return txt

and changed the language.py to load the doc throu it:

Code:
uni_doc = unicodeToAscii( file(language_path).read(), charset='latin-1' )
doc = xml.dom.minidom.parseString( uni_doc )
Now it does read the file, but substitutes accented chars with '?' (cos of the enocde replace)

Is there a better way ?
Retired from Add-on dev
Reply
#18
I've amended the shortcut creation to now create both _old and _new

Then prompts user if they wish to Switch to new, only if they choose to is the new copied to the bootable shortcut name.

Some new msgs as a result, could you translate these for me, then I'll post the amended code up here.

<string id="404">Switch</string>
<string id="405">Manual</string>


<string id="507">Copy existing data to T3CH ?</string>


<string id="519">_NEW and _OLD Shortcuts Created.</string>
<string id="520">_Switch to it NEW Now ?</string>
<string id="521">(Manual rename required otherwise)</string>


Thanks
Retired from Add-on dev
Reply
#19
try this:

XML

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<string id="10">Päävalikko</string> #this is finnish not swedish tho
etc etc.

return yourstring.decode("utf-8")

i find doing this for english does funny things tho.
So i added:

if self.language == "swedish":
return yourstring.decode("utf-8")
Reply
#20
BBB, blittans new file imports fine. make sure you saved it as utf-8 and not utf-8 cookie if your editor has that.

Also make sure you don't print or output to a device that only supports ascii, like xbmc debug window, with any of those characters in it.

And you can take my name out of the script and language file, but thanks for the mention.

I'll wait for your pm, but you could put other scripts in svn too, so if you want added. let me know.

Stanley, that decode() should not be necessary unless your doing as I said and outputting language strings to the debug window.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#21
BigBellyBilly Wrote:I've amended the shortcut creation to now create both _old and _new

Then prompts user if they wish to Switch to new, only if they choose to is the new copied to the bootable shortcut name.

Some new msgs as a result, could you translate these for me, then I'll post the amended code up here.

<string id="404">Byt</string>
<string id="405">Manuellt</string>

<string id="507">Kopiera existerande data till T3CH ?</string>

<string id="519">_NEW and _OLD genvägar skapade.</string>
<string id="520">_Byt till NEW genväg nu ?</string>
<string id="521">(Manuell omdöpning krävs annars)</string>


Thanks

There you go (Där har du *translated too*) Wink
Reply
#22
Tweaked v1.0 b9 from HERE

Changes are:
Swedish language updated by Blitten
Finnish language updated by mikko70
(I hope the translations don't read 'I like shaggin sheep!' )

New shortcut now written to c:\<dash_name>.cfg_new instead of directly over current shortcut.
Then user prompted if they wish to switch. If they do, shortcut copied from .cfg_new to .cfg otherwise user will have to ftp in and rename it.

Slight mod to language.py for as it was throwing an exception with some accented chars. Unfortunately this encoding causes the accented chars to be replaced with '?' It was either that or the minidom parser threw an exception. If you know of a better solution, please let me know (or better still send a working mod)

A couple of other minor changes.

Seems quite stable now. Unless something creeps out over the weekend, then I'll ask Nuka to help me with submitting to SVN.
Retired from Add-on dev
Reply
#23
Nuka1195 Wrote:BBB, blittans new file imports fine. make sure you saved it as utf-8 and not utf-8 cookie if your editor has that.

Also make sure you don't print or output to a device that only supports ascii, like xbmc debug window, with any of those characters in it.

And you can take my name out of the script and language file, but thanks for the mention.

I'll wait for your pm, but you could put other scripts in svn too, so if you want added. let me know.

Stanley, that decode() should not be necessary unless your doing as I said and outputting language strings to the debug window.

As i stated already.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#24
sorry I didnt seem to get notification of your post, so I missed a few.

Editor: I guess that wouldnt include Notepad then !? can you recommend a suitable one ?

thanks
Retired from Add-on dev
Reply
#25
BigBellyBilly Wrote:Editor: I guess that wouldnt include Notepad then !? can you recommend a suitable one ?
thanks

http://notepad-plus.sourceforge.net/uk/site.htm
cheers,

crazyivan
Reply
#26
you use windows notepad? for editing scripts?

If you do grab scite, i have an updated version that colors all xbmc, xbmcgui and xbmcplugin methods their own color. Plus most python keywords are highlighted.

Let me know if you want to use it and i can post the updates.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#27
Without that .decode, it shows in-correct characters in list items and labels etc :-(

Actually, scrap that - I changed my language file over to your one (nuka1195) in xbmc lyrics and works great.
This might solve all those bloody language issues i had :-D

Oh, permission to use your language class? credit of course!
Reply
#28
Both Finnish and Swedish strings is saved ansi format.
Strings need save UTF-8 format, then works right.
Reply
#29
no, just notepad for editing the xml. I use Pythonwin IDE for scripts

I downloaded blitten language xml file from pastebin and ftp'd it over without it touching an editor, and it still caused the parser to throw an exception. removing the accents and it was ok.

I'll grab that editor and try again.
Retired from Add-on dev
Reply
#30
ok. I installed scite
Loaded Swedish xml and changed encoding to utf-8 (not cookie) and saved.
Using Filezilla, ftp'd it and an original unmodified language.py to xbmc and I still got this exception in the log:

ERROR: Language file Q:\scripts\T3CH Upgrader\resources\language\swedish\strings.xml can't be parsed!

?
Retired from Add-on dev
Reply
  • 1
  • 2(current)
  • 3
  • 4
  • 5
  • 33

Logout Mark Read Team Forum Stats Members Help
[XBOX] T3CH Upgrader (Python Script)1