FabricMC / fabric-docs

[WIP] Official curated documentation for Fabric, a modding toolchain for Minecraft.
https://docs.fabricmc.net
Other
39 stars 39 forks source link

Author usernames should not be translatable #90

Open its-miroma opened 2 months ago

its-miroma commented 2 months ago

Usernames of authors are currently translatable in Crowdin.

Example: https://github.com/FabricMC/fabric-docs/blob/main/develop/events.md?plain=1#L4-L15

IMB11 commented 2 months ago

Not really much we can do about this, as we can't disable the translation of yml frontmatter without disabling the ability to translate the page title and description.

its-miroma commented 2 months ago

I'm not super familiar with Crowdin's configuration, but if I understand correctly you can add custom rules to ignore some sections in files. See https://support.crowdin.com/custom-segmentation

After experimenting on https://regex101.com, I think this may work:

<rule break="yes">
    <beforebreak>\A---\n(?:(?!---\n).*\n)*?authors:\n</beforebreak>
    <afterbreak> *+(?!- )</afterbreak>
</rule>
/regex/ explanation These regexes rely on lookarounds, which Crowdin should support. ### `beforebreak` - `\A`: assert position at the beginning of the string (aka file) - `---\n`: make sure we're inside of the frontmatter - `(?:(?!---\n).*\n)*?`: match all lines before `authors:` in the frontmatter - `(?:...)*?`: match zero or more lines lazily, to stop when reaching `authors:` below - `(?!---\n)`: a negative lookahead to make sure we're still in the frontmatter. If this matches, then the file does not mention any authors - `.*\n`: match zero or more characters followed by a newline - `authors:\n`: match the `authors:` line - the break starts here ### `afterbreak` - the break ends if this matches - ` *+`: match zero or more spaces greedily (aka ignore indentation) - I'm pretty sure that YAML only supports spaces, but if that's not the case you can substitute this with `[ \t]*+` to also match tabs - `(?!- )`: negative lookahead for `- ` (aka make sure there are no more authors)
IMB11 commented 2 months ago

This is only for manual XML/HTML based uploads, we use a different system to upload translations that doesn't support segments.