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

Dont upload placeholder strings to Weblate #805

Open
verhovsky opened this issue Aug 11, 2024 · 2 comments
Open

Dont upload placeholder strings to Weblate #805

verhovsky opened this issue Aug 11, 2024 · 2 comments

Comments

@verhovsky
Copy link
Contributor

verhovsky commented Aug 11, 2024

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.

@bryceco
Copy link
Owner

bryceco commented Aug 12, 2024

As mentioned towards the end of #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
Copy link
Owner

bryceco commented Aug 12, 2024

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=""))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants