[PATCH 1/2] Models: translate the user entered weight units

Linus Torvalds torvalds at linux-foundation.org
Fri Jan 3 09:03:23 UTC 2014


On Fri, Jan 3, 2014 at 4:49 AM, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
> From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
>
> Post c49d3885f this patch should make the input field
> in the equipment tab for weight to accept the user
> translated strings.

No, this is broken, for a few reasons.

> -       if (!strncmp(end, "kg", 2))
> +       if (!strncmp(end, tr("kg").toUtf8().data(), 2))
>                 goto kg;

That "2" is now no longer sensible (same goes for the 3 for "lbs".

That could probably be fixed by just stripping spaces from the end and
then just using "strcmp".

I'm also not entirely sure it makes sense to *replace* the check for kg/lbs.

I think you might want to do it in *addition* to kg/lbs, so that the
localized version is also accepted, but I do not think you should drop
support for "lbs" just because you might be in (say) a german locale
and using metric units. If you then want to input stuff using a US
unit, you might well want to use "lbs" rather than some German
translation that doesn't actually make any sense at all, since Germans
aren't crazy enough to ever *use* lbs anyway.

So from a pure UI standpoint, I really think it makes more sense to
accept "lbs" than some translation.

In particular, remember: if the string is some translation of the
standard unit, matching _that_ doesn't even *matter*, because it will
be matched by default by simply matching the locale setting (which
will always match the translated unit name, since that is where it
came from). See?

But accepting both might be fine. But in this form I really think the
patch is fundamentally broken.

              Linus


More information about the subsurface mailing list