Opened 14 years ago

Closed 13 years ago

#7697 closed bug (fixed)

[AboutSystem] Link to MIT licence looks strange when localized

Reported by: taos Owned by: nobody
Priority: normal Milestone: R1
Component: Applications/AboutSystem Version: R1/Development
Keywords: localization Cc:
Blocked By: Blocking:
Platform: All

Description

Using r1a3-rc-hrev42159.

When using the german localization, the link "MIT licence" (string: ... %MIT licence% ...) in AboutSystem is displayed as "%IT Lizenz%" instead of "MIT Lizenz".

Link to MIT licence in AboutSystem (german localization).

Attachments (13)

MIT_link.png (46.9 KB ) - added by taos 14 years ago.
Link to MIT licence in AboutSystem (german localization).
es.png (1.5 KB ) - added by taos 14 years ago.
Spanish localization.
it.png (1.4 KB ) - added by taos 14 years ago.
Italian localization.
fr.png (1.5 KB ) - added by taos 14 years ago.
French localization.
de.png (764 bytes ) - added by taos 14 years ago.
German localization.
en.png (653 bytes ) - added by taos 14 years ago.
No localization.
fi.png (1.1 KB ) - added by taos 14 years ago.
Finnish localization.
nl.png (668 bytes ) - added by taos 14 years ago.
Dutch localization.
AboutSystem_no_Chars.png (44.5 KB ) - added by taos 14 years ago.
Screenshot of patched AboutSystem (German localization).
AboutSystem.cpp.patch (977 bytes ) - added by taos 14 years ago.
Patch to fix display of MIT license link (compatible with current catkeys in alpha3-rc).
AboutSystem.cpp.consistent_spelling_of_license.patch (1.7 KB ) - added by taos 14 years ago.
Patch to fix display of MIT license link and introduces consistent spelling of license (needs new catkeys).
AboutSystem_updated_r42387.patch (1.7 KB ) - added by taos 13 years ago.
Updated patch to fix display of MIT license link and to introduce consistent spelling of "license".
AboutSystem_updated_r42512.patch (1.7 KB ) - added by taos 13 years ago.
Updated patch to fix display of MIT license link and to introduce consistent spelling of "license".

Download all attachments as: .zip

Change History (31)

by taos, 14 years ago

Attachment: MIT_link.png added

Link to MIT licence in AboutSystem (german localization).

comment:1 by richienyhus, 14 years ago

This looks like a translation error from overzealous translation to me.

comment:2 by taos, 14 years ago

Here are the corresponding excerpts from AboutSystem.cpp:

BPath mitPath;
_GetLicensePath("MIT", mitPath);
// Haiku license
BString haikuLicence = B_TRANSLATE("The code that is unique to Haiku, "
	"especially the kernel and all code that applications may link "
	"against, is distributed under the terms of the %MIT licence%. "
	"Some system libraries contain third party code distributed under the "
	"LGPL license. You can find the copyrights to third party code below.\n"
	"\n");
int32 licencePart1 = haikuLicence.FindFirst("%");
int32 licencePart2 = haikuLicence.FindLast("%");
BString part;
haikuLicence.CopyCharsInto(part, 0, licencePart1 );
fCreditsView->Insert(part);
	part.Truncate(0);
haikuLicence.CopyCharsInto(part, licencePart1 + 1, licencePart2 - 1
	- licencePart1);
fCreditsView->InsertHyperText(part, new OpenFileAction(mitPath.Path()));
	part.Truncate(0);
haikuLicence.CopyCharsInto(part, licencePart2 + 1, haikuLicence.CountChars()
	- licencePart2);
fCreditsView->Insert(part);

Any ideas? The French version displays "%licnce MIT%" (catkeys: %licence MIT%), the Russian "%MIT licence%", the Finnish "%MT licence%-isenssin" (catkeys: %MIT licence%-lisenssin). It doesn't even show the correct phrase without %s if this part of the string isn't translated at all. Only the non-localized English variant works.

BTW, apart from this sentence, the spelling "license" is used everywhere else in AboutSystem.

Last edited 14 years ago by taos (previous) (diff)

comment:3 by richienyhus, 14 years ago

It should be license which is American English, whilst the spelling licence is British English.

Last edited 14 years ago by richienyhus (previous) (diff)

comment:4 by siarzhuk, 14 years ago

IMO this is an excessive localization - the names of licenses must not be localized at all, because it breaks the "click and read" functionality in the list of installed software.

in reply to:  4 comment:5 by taos, 14 years ago

Replying to siarzhuk:

IMO this is an excessive localization - the names of licenses must not be localized at all, because it breaks the "click and read" functionality in the list of installed software.

I've also noticed this (see #7491 AboutSystem: clicking on localized license name doesn't open license file). But in this case, the "click and read" functionality works fine in a localized system. It's only the graphical representation of the licence name that is a little odd - even if the licence name itself isn't translated. At the moment, if you don't translate this part of the string you'll still get "%MIT licence%" instead of "MIT licence". Only in an English system, the %s are cut as intended.

comment:6 by taos, 14 years ago

Okay, call me completely mad. I think I found the problem: Characters with diacritics (e.g. é, ö, ñ) are counted twice (but why?). Therefore, the string is cut into parts at the wrong places. Instead of cutting out the %s (... |%|MIT...|%| ...), the cut position is shifted (e.g. ... %|M|IT...%| |...).

There is a linear correlation between the number of characters with diacritics in the translated string before %MIT...% and the shifting of the cut position.

language number of diacritics shift of cutting position cutting positions image
English 0 0 |%|MIT licence|%|. No localization.
Dutch 0 0 |%|MIT-licence|%|. Dutch localization.
German 1 +1 %|M|IT Lizenz%|.| German localization.
Italian 2 +2 %l|i|cenza MIT%.| |Alcun Italian localization.
Finnish 2 +2 %M|I|T licence%-|l|isenssin Finnish localization.
French 4 +4 %lic|e|nce MIT%. Q|u|elques French localization.
Spanish 5 +5 %lice|n|cia MIT%. Al|g|una Spanish localization.

Any ideas how to solve this?

Version 0, edited 14 years ago by taos (next)

by taos, 14 years ago

Attachment: es.png added

Spanish localization.

by taos, 14 years ago

Attachment: it.png added

Italian localization.

by taos, 14 years ago

Attachment: fr.png added

French localization.

by taos, 14 years ago

Attachment: de.png added

German localization.

by taos, 14 years ago

Attachment: en.png added

No localization.

by taos, 14 years ago

Attachment: fi.png added

Finnish localization.

by taos, 14 years ago

Attachment: nl.png added

Dutch localization.

comment:7 by axeld, 14 years ago

Hey, you're getting close! :-)

The problem you're describing happens because not each character uses up the same number of bytes (we're using UTF-8 encoding everywhere). While not apparent, the code in question mixes byte offsets/lengths with character offsets/lengths, and is therefore causing the problems. For example, FindFirst() is byte based, while CountChars() is character based.

in reply to:  7 comment:8 by taos, 14 years ago

Replying to axeld:

For example, FindFirst() is byte based, while CountChars() is character based.

Good to know. I've seen mentioned in The Haiku Book that CountChars() is aware of UTF8 and therefore counts the actual number of characters but I was not sure about FindFirst(), FindLast(), and Truncate().

So, is there already an easy way to make byte offsets compatible with character offsets? I guess something similar might have happened somewhere else in the haiku source code.

comment:9 by taos, 14 years ago

Hmmm, okay. If I replace CopyCharsInto() with CopyInto() and CountChars() with Length() the string is cut at the correct place - only both %s are removed as intended.

The graphical representation is okay (see screenshot below), the "click and read" functionality is still there (and at the correct place even in a Japanese or Russian system).

Screenshot of patched AboutSystem (German localization).

But, I'm not sure if removing the awareness of UTF8 in the code is the right way. However, if you're interested in a quick and dirty fix I can attach a patch file.

by taos, 14 years ago

Attachment: AboutSystem_no_Chars.png added

Screenshot of patched AboutSystem (German localization).

in reply to:  9 ; comment:10 by mmlr, 14 years ago

Replying to taos:

Hmmm, okay. If I replace CopyCharsInto() with CopyInto() and CountChars() with Length() the string is cut at the correct place - only both %s are removed as intended. ... But, I'm not sure if removing the awareness of UTF8 in the code is the right way.

The other way around would be the better way, i.e. replacing the calls with their *Chars() version instead. There are Find{First|Last}Chars() versions as well, so you can make all the calls Chars aware.

in reply to:  10 comment:11 by taos, 14 years ago

Replying to mmlr:

The other way around would be the better way, i.e. replacing the calls with their *Chars() version instead. There are Find{First|Last}Chars() versions as well, so you can make all the calls Chars aware.

Really? That's what I tried first, but I couldn't compile the changed code because of a "no matching function for call to..." error. I'll try again - might have been a typo on my side.

in reply to:  10 ; comment:12 by axeld, 14 years ago

Replying to mmlr:

The other way around would be the better way, i.e. replacing the calls with their *Chars() version instead. There are Find{First|Last}Chars() versions as well, so you can make all the calls Chars aware.

In this particular case, it doesn't really matter, as the '%' character is no UTF-8 character, and that's the only thing which matters for this code. So I think either solution would be fine. Patches welcome :-)

in reply to:  12 ; comment:13 by bonefish, 14 years ago

Replying to axeld:

In this particular case, it doesn't really matter, as the '%' character is no UTF-8 character, and that's the only thing which matters for this code. So I think either solution would be fine.

Since the *Char* variants are slower, I'd even say the non-UTF-8 aware solution is preferrable.

Patches welcome :-)

Ideally one also fixing the off-by-one error in the last CopyCharsInto() call.

in reply to:  13 ; comment:14 by taos, 14 years ago

Replying to bonefish:

Since the *Char* variants are slower, I'd even say the non-UTF-8 aware solution is preferrable.

Patches welcome :-)

Added two patches: First one (AboutSystem.cpp.patch) doesn't change the spelling of "licence" - can be used with the catkeys from HTA in alpha 3 branch. Second patch (AboutSystem.cpp.consistent_spelling_of_license.patch) changes the spelling to the US variant "license" but needs new catkeys.

Ideally one also fixing the off-by-one error in the last CopyCharsInto() call.

Not really sure???

comment:15 by taos, 14 years ago

patch: 01

in reply to:  14 ; comment:16 by bonefish, 14 years ago

Replying to taos:

Ideally one also fixing the off-by-one error in the last CopyCharsInto() call.

Not really sure???

It starts copying at index licencePart2 + 1, but copies haikuLicence.Length() - licencePart2 bytes, which is one too many. It doesn't really matter, since the method clamps the length anyway, but still no reason not to pass the correct value.

by taos, 14 years ago

Attachment: AboutSystem.cpp.patch added

Patch to fix display of MIT license link (compatible with current catkeys in alpha3-rc).

by taos, 14 years ago

Patch to fix display of MIT license link and introduces consistent spelling of license (needs new catkeys).

in reply to:  16 comment:17 by taos, 14 years ago

Replying to bonefish:

It starts copying at index licencePart2 + 1, but copies haikuLicence.Length() - licencePart2 bytes, which is one too many.

Thanks, I changed the patch files accordingly.

by taos, 13 years ago

Updated patch to fix display of MIT license link and to introduce consistent spelling of "license".

by taos, 13 years ago

Updated patch to fix display of MIT license link and to introduce consistent spelling of "license".

comment:18 by humdinger, 13 years ago

Resolution: fixed
Status: newclosed

Applied with hrev42514. Closing as fixed. We'll see if it finally nailed the bugger when the translated catkeys arrive. Thanks a lot.

Note: See TracTickets for help on using tickets.