WeblateOrg / weblate

Web based localization tool with tight version control integration.
https://weblate.org/
GNU General Public License v3.0
4.35k stars 970 forks source link

Monospace font #5859

Open roptat opened 3 years ago

roptat commented 3 years ago

Is your feature request related to a problem? If so, please describe.

Describe the solution you'd like

Some translations are for command-line tools that sometimes require alignment. It would be nice to have an option to switch to a monospace font, so counting spaces is easier :). A simple checkbox below the translation area or as an option in a dropdown menu would work well for this feature. It could be nice to be able to set a default for all languages on specific strings, but I could live without it.

Describe alternatives you've considered So, I can either try and copy the right number of spaces (counting them), or use the web console to force using a monospace font, as shown below.

Screenshots

Screenshot_2021-04-15 guix guix — French(1)

With a monospace font, the alignment is clearer:

Screenshot_2021-04-15 guix guix — French(2)

Same here:

Screenshot_2021-04-15 guix guix — Dutch

and then you discover easily the alignment was incorrect:

Screenshot_2021-04-15 guix guix — Dutch(1)

Additional context

comradekingu commented 3 years ago

The title of this should be changed to "Font rendering in translation field" or somesuch. There is a flag for specifying font, but it only concerns the max-length parameter https://docs.weblate.org/en/latest/admin/checks.html?highlight=font#fonts

So, no extra UI needed.

Instead of moving said strings to a component of its own, it could be done with flags (like now), only with rendering being a part of said flag. I don't see how rendering it in the WL UI in any particular font is anything but slightly less readable at worst.

roptat commented 3 years ago

Thanks for the comment, but this is not about measuring the width of strings, but about aligning strings more easily, as shown on the screenshots. Some of the translations are meant to be code fragments or printed on terminal, where we want strings to be aligned properly. So the solution to me is a button to switch to a different font, or to flag the string so it's shown in that font by default. If you mean adding a flag in the pot (or any other format) file, that's not so easy for developers I think.

fitojb commented 3 years ago

Weblate already makes use of Source Code Pro in some messages, so there’s no performance penalty in just using it in the editor fields

nijel commented 3 years ago

Switching to monospace font which we already should be doable. It could be toggled by a flag to allow string granularity (but it could be set on component level as well).

Using fonts defined for rendering would be nice, but that runs into serving user uploaded fonts, what could cause performance issues, and I'm also not sure about security here. The TTF fonts should probably work without a conversion, see https://caniuse.com/ttf.

yarons commented 2 years ago

It should also support RTL as Hebrew or Arabic needs some special aids to measure the distance while being written the other way around.