Hi,
unfortunately, it does not help.
I have digged a bit deeper and it has nothing to do with the namespaces and probably not even with msgcat. What I conclude is this:
Launching tclsh will not automatically load msgcat. When you [package require msgcat] from within tclsh, it will only provide you with the msgcat commands, but not look into the system locale and load some message catalogues. So, from that perspective everything is fine.
Launching wish (or [package require Tk]) is different. The file tk.tcl (in the library directory of Tk) will automatically be sourced when doing so and this file loads the msgcat package and also loads the tk message catalogue depending on the locale of the computer you are using. The catalogue with the translations is loaded into the ::tk namespace because it is there, it will be used (for TK's own widgets). And ... it will not interfere with the global namespace that is for the user in the first place. I think, this is the reason why the translations are not "exposed" to the user but "hidden" in the ::tk namespace.
So, the question is still there. Why does Tk not show German button texts in tk_messageBox on macOS when the locale is de_DE? My conclusion is - it is not msgcat that is broken, it is the implementation of tk_messageBox on macOS:
On macOS, tk_messageBox is implemented via a native 'alert' dialog window, not via $tk_library/msgbox.tcl. If I call that library function directly (::tk::MessageBox) I get a localized dialog, but the macOS implementation of tk_messageBox in tkMacOSXDialog.c is not able to use the msgcat catalogue as it seems.
The fact that tk_getOpenFile and tk_getSaveFile result in German text buttons, however, seems strange. Maybe, this is something on the OS level. I assume that macOS is making sure that the button texts are localized. The file dialogues just use some standard buttons while the alert buttons in macOS are custom. So, in tkMacOSXDialog.c we have these texts:
static const char *const alertButtonStrings[] = {
"abort", "retry", "ignore", "ok", "cancel", "no", "yes", NULL
};
static const NSString *const alertButtonNames[][3] = {
[TYPE_ABORTRETRYIGNORE] = {@"Abort", @"Retry", @"Ignore"},
[TYPE_OK] = {@"OK"},
[TYPE_OKCANCEL] = {@"OK", @"Cancel"},
[TYPE_RETRYCANCEL] = {@"Retry", @"Cancel"},
[TYPE_YESNO] = {@"Yes", @"No"},
[TYPE_YESNOCANCEL] = {@"Yes", @"No", @"Cancel"},
};
And in the alert, they are directly used for the buttons, without localization.
i = 0;
while (i < 3 && alertButtonNames[typeIndex][i]) {
alert addButtonWithTitle:(NSString*) alertButtonNames[typeIndex][i++]];
}
In summary, localization of tk_messageBox is missing in the mcOS implementation. Perhaps it can be done with a wrapper procedure in Tcl that gets the localized strings from the Tk message catalogue and hands them over to the implementation in Tk_MessageBoxObjCmd. This could be done in $tk_library/msgbox.tcl.
Torsten