From: <dwa...@us...> - 2011-03-11 19:56:13
|
Revision: 17299 http://translate.svn.sourceforge.net/translate/?rev=17299&view=rev Author: dwaynebailey Date: 2011-03-11 19:56:06 +0000 (Fri, 11 Mar 2011) Log Message: ----------- Add a UTF-8 dialect for Java properties files to overcome the potential confusion with .properties in UTF-8 instead of Latin1 Modified Paths: -------------- src/trunk/translate/storage/properties.py Modified: src/trunk/translate/storage/properties.py =================================================================== --- src/trunk/translate/storage/properties.py 2011-03-11 19:45:11 UTC (rev 17298) +++ src/trunk/translate/storage/properties.py 2011-03-11 19:56:06 UTC (rev 17299) @@ -287,20 +287,26 @@ register_dialect(DialectJava) +class DialectJavaUtf8(DialectJava): + name = "java-utf8" + default_encoding = "utf-8" + delimiters = [u"=", u":", u" "] + + def encode(cls, string, encoding=None): + return quote.mozillapropertiesencode(string or u"") + encode = classmethod(encode) +register_dialect(DialectJavaUtf8) + + class DialectFlex(DialectJava): name = "flex" default_encoding = "utf-8" register_dialect(DialectFlex) -class DialectMozilla(Dialect): +class DialectMozilla(DialectJavaUtf8): name = "mozilla" - default_encoding = "utf-8" delimiters = [u"="] - - def encode(cls, string, encoding=None): - return quote.mozillapropertiesencode(string or u"") - encode = classmethod(encode) register_dialect(DialectMozilla) @@ -541,6 +547,16 @@ super(javafile, self).__init__(*args, **kwargs) +class javafile(propfile): + Name = _("Java Properties (UTF-8)") + Exensions = ['properties'] + + def __init__(self, *args, **kwargs): + kwargs['personality'] = "java-utf8" + kwargs['encoding'] = "utf-8" + super(javafile, self).__init__(*args, **kwargs) + + class stringsfile(propfile): Name = _("OS X Strings") Extensions = ['strings'] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |