WeblateOrg / weblate

Web based localization tool with tight version control integration.
https://weblate.org/
GNU General Public License v3.0
4.53k stars 1k forks source link

Add support for read only state in exporters #4902

Open adriandiazgar opened 3 years ago

adriandiazgar commented 3 years ago

Describe the bug

When a string.xml for Android is uploaded to weblate, it considers the "translatable" attribute of the node and it makes the unit "read-only" which is OK.

The problem comes when downloading the file that doesn't contain the "translatable" attribute anymore which leads to being translatable again if the downloaded file is uploaded again.

To Reproduce the bug

Description should look similar to this:

Steps to reproduce the behavior:

  1. Upload file to an Android project like
<?xml version="1.0" encoding="utf-8"?>
<resources>
       <string name="app_name" translatable="false">this should be read only</string>
</resources>
  1. Navigate to the project and click on download file the content will look like
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
       <string name="app_name">this should be read only</string>
    </resources>

Expected behavior

Keep the read-only attribute after download it from weblate like:

<?xml version="1.0" encoding="utf-8"?>
<resources>
       <string name="app_name" translatable="false">this should be read only</string>
</resources>
nijel commented 3 years ago

I guess that you are downloading converted file instead of taking original. Is there any good reason for that?

The converters do not currently support flagging read only strings.

github-actions[bot] commented 3 years ago

This issue has been added to the backlog. It is not scheduled on the Weblate roadmap, but it eventually might be implemented. In case you need this feature soon, please consider helping or push it by funding the development.

adriandiazgar commented 3 years ago

Thanks for the quick response

Oh, I see @nijel yeah, it makes sense, I was downloading a converted version of it without thinking about downloading the original file.

But this brings me to wonder why there is a conversion step when the original file is Android and the requested file type is Android, would it make more sense to download directly the original file if the requested format is the same?

nijel commented 3 years ago

There is no additional logic in place = it gives you whatever you've requested. It still might make sense in some situations because the exported files can contain additional data such as comments or suggestions which are (for good reasons) not present in the original files.

nijel commented 3 months ago

The unit state should be handled somewhere here:

https://github.com/WeblateOrg/weblate/blob/e25a5ee0608dc9e8f60cb7ac4e65ef34cf1bddb0/weblate/formats/exporters.py#L185-L203