Commit bcc342c9 authored by Michal Čihař's avatar Michal Čihař

Improved support for translating PHP files.

This is really just a workaround for translate-toolkit bug, but it's way
simpler than trying to fix .save() for translate-toolkit phpfile...

Fixes #910
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent a1d0b28e
...@@ -18,6 +18,7 @@ Released on ? 2015. ...@@ -18,6 +18,7 @@ Released on ? 2015.
* Improve quality checks for Armenian. * Improve quality checks for Armenian.
* Support for starting translation components without existing translations. * Support for starting translation components without existing translations.
* Support for adding new transations in Qt TS. * Support for adding new transations in Qt TS.
* Improved support for translating PHP files.
weblate 2.4 weblate 2.4
----------- -----------
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
File format specific behavior. File format specific behavior.
''' '''
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from translate.convert import po2php, convert
from translate.storage.lisa import LISAfile from translate.storage.lisa import LISAfile
from translate.storage.properties import propunit, propfile from translate.storage.properties import propunit, propfile
from translate.storage.xliff import xliffunit, xlifffile from translate.storage.xliff import xliffunit, xlifffile
...@@ -1013,6 +1014,21 @@ class PhpFormat(FileFormat): ...@@ -1013,6 +1014,21 @@ class PhpFormat(FileFormat):
''' '''
return 'php' return 'php'
def save(self):
'''
Saves underlaying store to disk.
This is workaround for .save() not working as intended in
translate-toolkit.
'''
with open(self.store.filename, 'r') as handle:
convertor = po2php.rephp(handle, self.store)
outputphplines = convertor.convertstore(False)
with open(self.store.filename, 'w') as handle:
handle.writelines(outputphplines)
@register_fileformat @register_fileformat
class RESXFormat(FileFormat): class RESXFormat(FileFormat):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment