Weblate: Wrong link to original source for github submodule

Created on 28 Apr 2018  Â·  14Comments  Â·  Source: WeblateOrg/weblate

All 14 comments

Probably @akien-mga could take a look...

Thanks for the ping @nijel.

I'm not sure it can be solved properly with the way we set up our https://github.com/godotengine/godot-docs-l10n repository.

The source files are in the docs submodule, which as mentioned above, cannot be used to link to a file directly with e.g. https://github.com/godotengine/godot-docs-l10n/docs/getting_started/scripting/gdscript/gdscript_advanced.rst#L390

Weblate lets us configure the URL to resolve to (default is https://github.com/godotengine/godot-docs-l10n/blob/%(branch)s/%(file)s#L%(line)s), so in theory it could be changed to point to https://github.com/godotengine/godot-docs, but the problem is that %(file) in our case is a relative path to the docs submodule, e.g. (for the above URL) docs/​getting_started/​scripting/​gdscript/​gdscript_advanced.rst, while for the godot-docs repo we'd need that path without the docs/ prefix.

I can think of two solutions:

  • On the Weblate side, provide a way to configure how %(file) is inferred from the location hint (../​../​docs/​getting_started/​scripting/​gdscript/​gdscript_advanced.rst:390). Currently it properly resolves the relative path to start at the repository's root, but in our case we'd need a way to filter out the docs/ folder. I'm not sure how to do this usability wise though, and not sure if it's worth the effort, unless other projects have similar issues.
  • On the Godot side, I could just sed the docs/ part of the hint away, and then Weblate's %(file) should be usable for our godot-docs repo. The drawback is that people doing local translation with a checked out submodule would get a broken location path - but we don't really support that workflow anyway, so it's probably not too bad.
  • On the Godot side, I could just sed the docs/ part of the hint away, and then Weblate's %(file) should be usable for our godot-docs repo. The drawback is that people doing local translation with a checked out submodule would get a broken location path - but we don't really support that workflow anyway, so it's probably not too bad.

One question for @nijel though: if I were to remove the whole ../../docs/ part of the path instead of just docs/, would that break the logic that determines %(file), or is it clever enough to find its way?

I haven't read all the comments, just quick note: You can also use relative paths like %(../../file)s, see https://docs.weblate.org/en/latest/admin/projects.html#component-configuration

In my case I would need to remove the docs/ part already contained in %(file)s, so unless it supports a syntax for substring deletions like Bash's %{file#docs/}, that won't work as is in this case. I'll go with the tweak to our location hint strings directly.

Though it wouldn't work in general, you may use https://github.com/godotengine/godot-%(file)s here... @akien-mga

That's exactly what %(../file)s does.

Thanks, that seems to be needed to get rid of the leading ../../ of my location hints, but it does not work to remove the docs/ prefix eventually.

Here's the output of several format strings, for this source hint: ../​../​docs/​getting_started/​scripting/​gdscript/​gdscript_advanced.rst:390:

This shows that %(../../file)s is needed to remove the leading ../../ of my hint string (otherwise it removes the blob/%(branch)s/ part), but can't be used to actually remve the docs/ part after those ../../.

Yes, probably you can't go beyond grandpa!

Seeing advance of different translations, seding source path string (to minimal possible path string) in English file shouldn't affect anyone, imho.
Unless it is actually used by weblate to identify strings ? (in that case currently translated .po should be saved, so they can be uploaded again..., while seding them too)

I've just added that option to the code, will deploy it later today.

Seems fixed. 👍

Yes, the new option added in bf2d557 seems to work great, thanks!

Thank you for your report, the issue you have reported has been fixed (and properly labeled as enhancement).

  • In case you see problem with the fix, please comment on this issue.
  • In case you see similar problem, please open separate issue.
  • If you are happy with the outcome, consider supporting Weblate by donating.
Was this page helpful?
0 / 5 - 0 ratings