Opened 8 years ago

Closed 7 years ago

#7873 closed bug (fixed)

B_TRANSLATE("String") between #ifdef and #endif not included in catalogs

Reported by: taos Owned by: zooey
Priority: normal Milestone: R1
Component: - General Version: R1/Development
Keywords: localization, HTA Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

Strings that are prepared for translation by using the translation macros (e.g. B_TRANSLATTE("String")) don't appear on HTA if they are part of #if USE_SSL ... #endif statements.

Example (/src/add-ons/mail_daemon/outbound_protocols/smtp/ConfigView.cpp):

{
#ifdef USE_SSL
	AddFlavor(B_TRANSLATE("Unencrypted"));
	AddFlavor(B_TRANSLATE("SSL"));
	AddFlavor(B_TRANSLATE("STARTTLS"));
#endif

	AddAuthMethod(B_TRANSLATE("None"), false);
	AddAuthMethod(B_TRANSLATE("ESMTP"));
	AddAuthMethod(B_TRANSLATE("POP3 before SMTP"), false);

[...]
	}

"None", "ESMTP", and "POP3 before SMTP" are included in the respective catalog files (e.g. sk.catkeys) whereas "Unencrypted", "SSL", and "STARTTLS" are missing from HTA.

Attachments (1)

BeMenu.png (60.3 KB) - added by taos 8 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 8 years ago by taos

Summary: B_TRANSLATE("String") between #if USE_SSL and #endif not included in catalogsB_TRANSLATE("String") between #ifdef and #endif not included in catalogs

More examples can be found in /src/apps/deskbar/BeMenu.cpp:

#ifdef HAIKU_DISTRO_COMPATIBILITY_OFFICIAL
	static const char* kAboutHaikuMenuItemStr = B_TRANSLATE_MARK(
		"About Haiku");
#else
	static const char* kAboutThisSystemMenuItemStr = B_TRANSLATE_MARK(
		"About this system");
#endif
#ifdef APM_SUPPORT
	static const char* kSuspendMenuItemStr = B_TRANSLATE_MARK("Suspend");

	if (_kapm_control_(APM_CHECK_ENABLED) == B_OK) {
		item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kSuspendMenuItemStr),
			new BMessage(kSuspendSystem));
		item->SetEnabled(!dragging);
		shutdownMenu->AddItem(item);
	}
#endif

From HTA (and thus from corresponding catkeys and catalog files), "About Haiku" and "Suspend" are missing. If building an image with --distro-compatibility official you'll get a Be Menu entry that's not translated:

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

Changed 8 years ago by taos

Attachment: BeMenu.png added

comment:2 Changed 8 years ago by pulkomandy

Owner: changed from nobody to pulkomandy
Status: newassigned

The solution is likely to use B_TRANSLATE_MARK outside the ifdef to mark the strings anyway (so collectcatkeys can find them).

comment:3 Changed 8 years ago by pulkomandy

Fixed in hrev42991. Please tell if you find other instances of it.

comment:4 Changed 8 years ago by pulkomandy

Resolution: fixed
Status: assignedclosed

comment:5 Changed 7 years ago by taos

Resolution: fixed
Status: closedreopened

Problem is back since update of catkeys from pootle in hrev44109. I suppose the culprit can be found after hrev44023 (previous translation update from pootle) - maybe due to changes in BCatalog?

comment:6 Changed 7 years ago by pulkomandy

BCatalog shouldn't be involved. The problem may be hat B_TRANSLATE_MARK macro doesn't work anymore, or maybe the preprocessor optimizing it away somehow.

The problem is http://cgit.haiku-os.org/haiku/commit/?id=541ff51a6ef4c47f8ab105ba6ff895cdbba83aca , the B_TRANSLATE macros changed meaning and this part of the code was not adjusted.

Are there other places besides Mail add-on SSL and BeMenu ?

comment:7 Changed 7 years ago by pulkomandy

Resolution: fixed
Status: reopenedclosed

Well, fixeed these two in hrev44205. Tell us if you see more.

comment:8 Changed 7 years ago by zooey

Resolution: fixed
Status: closedreopened

Thanks for cleaning up after me.

However, I think the fix indicates that switching back to using B_COLLECTING_CATKEYS when collecting the catalog keys is a good idea. With that macro, it wouldn't be necessary to give each string twice (once for marking and once for creating the menu item).

Reopening and taking the ticket, so I won't forget ...

comment:9 Changed 7 years ago by zooey

Owner: changed from pulkomandy to zooey
Status: reopenedassigned

comment:10 Changed 7 years ago by pulkomandy

Well, actually it's possible to revert to the scheme used before introduction of B_COLLECTING_CATKEYS :

static const char* kSomeString = B_TRANSLATE_MARK("Some String");

#ifdef FOO
// ...
new BMenuItem(B_TRANSLATE_NOCOLLECT(kSomeString));
// ...
#endif

The problem with this is the string could end up in the binary (didn't check if it actually happens)

So yes, having B_COLLECTING_CATKEYS around might still be helpful. It could be added in the jam rule as a preprocessor option, if we don't want it in an header.

comment:11 Changed 7 years ago by zooey

Resolution: fixed
Status: assignedclosed

Fixed in hrev44546, B_COLLECTING_CATKEYS is now back again.

Note: See TracTickets for help on using tickets.