Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flat XML - configure default tag names #3149

Closed
kgronowski opened this issue Oct 25, 2019 · 4 comments
Closed

Flat XML - configure default tag names #3149

kgronowski opened this issue Oct 25, 2019 · 4 comments
Labels
question This is more a question for the support than an issue. wontfix Nobody will work on this.

Comments

@kgronowski
Copy link

Hello,

I have a question about the flatxml format.
Is it possible to configure/customize default xml tag names that weblate should use when reading / creating new translation files as is possible using the appropriate options (root, value, key) in Translate Toolkit?

Basically I would like to change FlatXML format definition from

<root>
  <str key="hello_world">Hello World!</str>
  <str key="resource_key">Translated value.</str>
</root>

to e.g.

<dictionary xmlns="urn:translate-toolkit:flat-xml-dictionary">
  <entry name="hello_world">Hello World!</entry>
  <entry name="resource_key">Translated value.</entry>
</dictionary>
@kgronowski kgronowski changed the title Flat XML Flat XML - configure default tag names Oct 25, 2019
@nijel
Copy link
Member

nijel commented Oct 25, 2019

You currently need to define new file format in Weblate which would pass needed params. It's not possible to specify this on the UI, see #1897

@nijel nijel added the question This is more a question for the support than an issue. label Oct 25, 2019
@kgronowski
Copy link
Author

Thank you for your answer.
Unfortunately I'm not really familiar with Python and Django and I'm not sure how I am supposed to add new format with needed params. I assume that I should add/create something similar to what can be found in ttkit.py but where/how should I set my params for converter.

Btw, I'm using Docker container for Weblate.

@nijel
Copy link
Member

nijel commented Oct 28, 2019

The easiest approach seems to be to subclass FlatXMLFile overriding its __init__ and changing parameters to desired values. You can then use the newly defined class as loader in the Weblate format class:

class FlatXMLFormat(TTKitFormat):
name = _('Flat XML file')
format_id = 'flatxml'
loader = ('flatxml', 'FlatXMLFile')
monolingual = True
unit_class = FlatXMLUnit
new_translation = (
'<?xml version="1.0" encoding="utf-8"?>\n<root></root>'
)

@stale
Copy link

stale bot commented Nov 7, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix Nobody will work on this. label Nov 7, 2019
@stale stale bot closed this as completed Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This is more a question for the support than an issue. wontfix Nobody will work on this.
Projects
None yet
Development

No branches or pull requests

2 participants