GoMap icon indicating copy to clipboard operation
GoMap copied to clipboard

Dont upload placeholder strings to Weblate

Open verhovsky opened this issue 1 year ago • 2 comments

There are a bunch of strings on Weblate that say "Note = "Placeholder - Do not translate";", for example Base.lproj/MainStoryboard.storyboard///1tR-eI-DSh.configuration.title. Please remove them so I don't have to click past them to check for new things to translate and so that 100% translated will actually mean 100% translated.

verhovsky avatar Aug 11 '24 11:08 verhovsky

As mentioned towards the end of https://github.com/bryceco/GoMap/issues/742 we don't have an easy way to do this currently, because there's no way in Xcode to mark a string as not needing localization. And as far as I'm aware there's no way to mark a string in XLIFF as read-only. The current approach is to do a bulk-edit of the Weblate database adding flag:read-only to strings with note:"Placeholder - Do not translate"

I guess a better solution is to have a script that runs after exporting XLIFFs that searches each one for the "Placeholder" text and then deletes the surrounding string.

bryceco avatar Aug 12 '24 18:08 bryceco

I tried to fix it using the script below. Unfortunately it breaks things:

  • Quotemarks (") get replaced with "
  • 	 gets changed to a tab character.
  • Miscellaneous other encoding conversions.
#!/usr/bin/python3

# Look though an xliff file and delete translation units that contain Note = Placholder

import sys, os
from xml.dom.minidom import parse

filename = sys.argv[1]
document = parse(filename)

tag = "Note = \"Placeholder -".lower()
# print(tag)

notes = document.getElementsByTagName("note")
for note in notes:
	child = note.firstChild
	if child != None:
		value = child.nodeValue
		if tag in value.lower():
			# print(value)
			# Remove the parent
			transUnit = note.parentNode
			body = transUnit.parentNode
			body.removeChild(transUnit)
print(document.toprettyxml(indent=" ",newl=""))

bryceco avatar Aug 12 '24 20:08 bryceco