[PATCH 1/2] Models: translate the user entered weight units
Dirk Hohndel
dirk at hohndel.org
Fri Jan 3 09:08:25 UTC 2014
On Fri, 2014-01-03 at 09:03 -0800, Linus Torvalds wrote:
> 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,
That's what we do for GPS coordinates as well.
> 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.
Worse, Germans ARE crazy enough to use "pounds", but of course they are
metric pounds, i.e. 500g or 0.5kg...
> So from a pure UI standpoint, I really think it makes more sense to
> accept "lbs" than some translation.
I think we should accept whatever the translator sets as translation,
e.g. "US Pfund".
> 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?
I don't understand that last sentence. I think we should compare to
"lbs" and tr("lbs") and accept both. Same for "kg".
> But accepting both might be fine. But in this form I really think the
> patch is fundamentally broken.
Yes, with the length fixed it's definitely broken.
/D
More information about the subsurface
mailing list