From 7758e371f4655a4ff09abe38a7b56c07381c024d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sundstr=C3=B6m?= Date: Tue, 22 Mar 2011 22:09:35 +0000 Subject: [PATCH] Enable localization of Tracker add-on names and shortcuts, with the canonical name and shortcut as fallback. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41085 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/ContainerWindow.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index 19001a3d68..e7291eeed1 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -166,15 +166,26 @@ ActivateWindowFilter(BMessage *, BHandler **target, BMessageFilter *) static void StripShortcut(const Model *model, char *result, uint32 &shortcut) { - strcpy(result, model->Name()); + // model name (possibly localized) for the menu item label + strlcpy(result, model->Name(), B_FILE_NAME_LENGTH); - // check if there is a shortcut + // check if there is a shortcut in the model name uint32 length = strlen(result); - shortcut = '\0'; - if (result[length - 2] == '-') { + if (result[length - 2] == '-' && length > 2) { shortcut = result[length - 1]; result[length - 2] = '\0'; + return; } + + // check if there is a shortcut in the filename + char* refName = model->EntryRef()->name; + length = strlen(refName); + if (refName[length - 2] == '-' && length > 2) { + shortcut = refName[length - 1]; + return; + } + + shortcut = '\0'; }