fkirc / attranslate

A command line tool for translating JSON, YAML, CSV, ARB, XML (via a CLI)
https://www.npmjs.com/package/attranslate
Other
336 stars 27 forks source link

xml translate not works with specific type of xml file #238

Closed johnfelipe closed 1 year ago

johnfelipe commented 2 years ago

https://github.com/statisticssweden/PxWeb/blob/master/PXWeb/Resources/Languages/pxlang.xml

attranslate --srcFile=pxlang.xml --srcLng=en --srcFormat=xml --targetFile=pxlang-es.xml --targetLng=es --targetFormat=xml --service=google-translate --serviceConfig=traducciones-352415-79659df1c6f1.json

Bypass 1285 strings because they are empty...
Add 1285 new translations
Write target '/root/attranslate/pxlang-es.xml'

how can solve this?

fkirc commented 2 years ago

Hi, Unfortunately, the current XML-translation is pretty much limited to Android-XMLs. To make it more usable for Non-Android-XMLs, we would probably need a rewrite of the XML-code. Right now, I cannot do any rewrite because I am blocked with other projects, but I would be happy to merge a PR.

johnfelipe commented 2 years ago

but may be can do translate to xml appropiate of your app can you share me a link with an example? i will create a regex for try and test agree?

fkirc commented 2 years ago

As an example-XML, you can take a look at the XMLs in https://github.com/fkirc/attranslate/tree/master/sample-scripts/xml-generic or in https://github.com/fkirc/attranslate/tree/master/sample-scripts/android/app/src/main/res. This should give you an idea about the currently supported XMLs.

Now to improve the XML-support for your specific XMLs and other XMLs, we could modify the code in https://github.com/fkirc/attranslate/tree/master/src/file-formats/xml. But I am not sure whether small improvements are enough, or whether a complete rewrite of this XML-code is necessary.

johnfelipe commented 2 years ago

i will translate this https://github.com/statisticssweden/PxWeb/blob/master/PXWeb/Resources/Languages/pxlang.xml

to this

https://github.com/fkirc/attranslate/blob/master/sample-scripts/xml-generic/en.xml

with regex

summary

<sentence name="CtrlChangeTextsText" value="Make your text changes and press 'Continue'"/> to

<sentence name="CtrlChangeTextsText">Make your text changes and press 'Continue'> its fine?

fkirc commented 2 years ago

Yeah, I think that the current implementation expects to have the text between XML-tags, so it might work with a regex-transformation.

fkirc commented 1 year ago

I am still unsure what to do with the current XML-feature. I know that there are limitations with the XML-feature, but I currently do not have the resources to rewrite the XML-feature.

I am closing the issue for now, but please feel free to re-open the issue if it is still relevant.