From bc622f6b593445f16011614d1b936c9761096f21 Mon Sep 17 00:00:00 2001 From: Humdinger Date: Tue, 16 Oct 2018 07:43:34 +0200 Subject: [PATCH] Fix missing localization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This addresses some of what's reported in ticket #14637. * Keymap preferences: Localize key labels. Translators have to be careful not too use too long words here... * Media preferences: Fix typo "SoundFonts" -> "SoundFont" The two popup menus, Video input/output, both use "", which when the catkeys are collected is reduced to one item. Apparently, Italian likes to have different tranlsations for them. I hope to fix that by using B_TRANSLATE_COMMENT with differing comments. Not sure if that'll work... * Network preferences: Localize "on/off" and "Enable/Disable" in the Services. * Repositories preferences: Add RepoRow.cpp to DoCatalogs. * Shortcuts preferences: Localize "Left/Right/Both/Either/None" * Bluetooth replicant: Localize menu items and alerts. * DeskCalc: Localize button names. * HaikuDepot: - Use BStringFormat and variables to replace for the WorkStatusView. - Put package name in single quotes; nicer if you have package names with spaces. - Avoid leading and trailing spaces in translatable strings. Those can be overlooked b the translator. - Use B_UTF8_ELLIPSIS instead of "...". Change-Id: Ia32908f9faad5188aa87c918c31229277decbda9 Reviewed-on: https://review.haiku-os.org/631 Reviewed-by: Jérôme Duval --- src/apps/deskcalc/CalcView.cpp | 46 ++++++------ src/apps/haikudepot/ui/MainWindow.cpp | 4 +- src/apps/haikudepot/ui/UserLoginWindow.cpp | 5 +- src/apps/haikudepot/ui/WorkStatusView.cpp | 25 ++++--- src/kits/media/Jamfile | 6 ++ src/preferences/keymap/KeyboardLayoutView.cpp | 73 ++++++++++++------- src/preferences/media/MediaViews.cpp | 8 +- src/preferences/media/MidiSettingsView.cpp | 2 +- src/preferences/network/InterfaceView.cpp | 3 +- src/preferences/network/ServiceListItem.cpp | 8 +- src/preferences/repositories/Jamfile | 1 + src/preferences/repositories/RepoRow.cpp | 8 +- src/preferences/shortcuts/ShortcutsSpec.cpp | 10 +-- src/servers/bluetooth/DeskbarReplicant.cpp | 20 +++-- src/servers/bluetooth/Jamfile | 8 +- 15 files changed, 143 insertions(+), 84 deletions(-) diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp index a17758929b..2b7d510be6 100644 --- a/src/apps/deskcalc/CalcView.cpp +++ b/src/apps/deskcalc/CalcView.cpp @@ -78,14 +78,14 @@ static const float kMinimumHeightScientific = 200.0f; static const float kMaximumHeightScientific = 400.0f; // basic mode keypad layout (default) -const char *kKeypadDescriptionBasic = +const char *kKeypadDescriptionBasic = B_TRANSLATE_MARK( "7 8 9 ( ) \n" "4 5 6 * / \n" "1 2 3 + - \n" - "0 . BS = C \n"; + "0 . BS = C \n"); // scientific mode keypad layout -const char *kKeypadDescriptionScientific = +const char *kKeypadDescriptionScientific = B_TRANSLATE_MARK( "ln sin cos tan π \n" "log asin acos atan sqrt \n" "exp sinh cosh tanh cbrt \n" @@ -93,7 +93,7 @@ const char *kKeypadDescriptionScientific = "7 8 9 ( ) \n" "4 5 6 * / \n" "1 2 3 + - \n" - "0 . BS = C \n"; + "0 . BS = C \n"); enum { @@ -1214,28 +1214,30 @@ CalcView::_PressKey(int key) assert(key < (fRows * fColumns)); assert(key >= 0); - if (strcmp(fKeypad[key].label, "BS") == 0) { + if (strcmp(fKeypad[key].label, B_TRANSLATE_COMMENT("BS", + "Key label, 'BS' means backspace")) == 0) { // BS means backspace fExpressionTextView->BackSpace(); - } else if (strcmp(fKeypad[key].label, "C") == 0) { + } else if (strcmp(fKeypad[key].label, B_TRANSLATE_COMMENT("C", + "Key label, 'C' means clear")) == 0) { // C means clear fExpressionTextView->Clear(); - } else if (strcmp(fKeypad[key].label, "acos") == 0 - || strcmp(fKeypad[key].label, "asin") == 0 - || strcmp(fKeypad[key].label, "atan") == 0 - || strcmp(fKeypad[key].label, "cbrt") == 0 - || strcmp(fKeypad[key].label, "ceil") == 0 - || strcmp(fKeypad[key].label, "cos") == 0 - || strcmp(fKeypad[key].label, "cosh") == 0 - || strcmp(fKeypad[key].label, "exp") == 0 - || strcmp(fKeypad[key].label, "floor") == 0 - || strcmp(fKeypad[key].label, "log") == 0 - || strcmp(fKeypad[key].label, "ln") == 0 - || strcmp(fKeypad[key].label, "sin") == 0 - || strcmp(fKeypad[key].label, "sinh") == 0 - || strcmp(fKeypad[key].label, "sqrt") == 0 - || strcmp(fKeypad[key].label, "tan") == 0 - || strcmp(fKeypad[key].label, "tanh") == 0) { + } else if (strcmp(fKeypad[key].label, B_TRANSLATE("acos")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("asin")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("atan")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("cbrt")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("ceil")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("cos")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("cosh")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("exp")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("floor")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("log")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("ln")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("sin")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("sinh")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("sqrt")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("tan")) == 0 + || strcmp(fKeypad[key].label, B_TRANSLATE("tanh")) == 0) { int32 labelLen = strlen(fKeypad[key].label); int32 startSelection = 0; int32 endSelection = 0; diff --git a/src/apps/haikudepot/ui/MainWindow.cpp b/src/apps/haikudepot/ui/MainWindow.cpp index b6d8733d62..647dc18289 100644 --- a/src/apps/haikudepot/ui/MainWindow.cpp +++ b/src/apps/haikudepot/ui/MainWindow.cpp @@ -1250,7 +1250,7 @@ MainWindow::_StartRefreshWorker(bool force) if (parameters == NULL) return; - fWorkStatusView->SetBusy(B_TRANSLATE("Refreshing...")); + fWorkStatusView->SetBusy(B_TRANSLATE("Refreshing" B_UTF8_ELLIPSIS)); ObjectDeleter deleter(parameters); fModelWorker = spawn_thread(&_RefreshModelThreadWorker, "model loader", @@ -1304,7 +1304,7 @@ MainWindow::_PackageActionWorker(void* arg) BMessenger messenger(window); BMessage busyMessage(MSG_PACKAGE_WORKER_BUSY); BString text(ref->Label()); - text << "..."; + text << B_UTF8_ELLIPSIS; busyMessage.AddString("reason", text); messenger.SendMessage(&busyMessage); diff --git a/src/apps/haikudepot/ui/UserLoginWindow.cpp b/src/apps/haikudepot/ui/UserLoginWindow.cpp index 89cfd85ee7..217be01e10 100644 --- a/src/apps/haikudepot/ui/UserLoginWindow.cpp +++ b/src/apps/haikudepot/ui/UserLoginWindow.cpp @@ -678,8 +678,9 @@ UserLoginWindow::_CreateAccountThread() } else if (message == "validationerror") { _CollectValidationFailures(result, error); } else { - error << B_TRANSLATE(" It responded with: "); - error << message; + BString response = B_TRANSLATE("It responded with: %message%"); + response.ReplaceFirst("%message%", message); + error << " " << response; } } } diff --git a/src/apps/haikudepot/ui/WorkStatusView.cpp b/src/apps/haikudepot/ui/WorkStatusView.cpp index d9d43b096e..615388b3bd 100644 --- a/src/apps/haikudepot/ui/WorkStatusView.cpp +++ b/src/apps/haikudepot/ui/WorkStatusView.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -144,12 +145,11 @@ void WorkStatusView::_SetTextPendingDownloads() { BString text; - const size_t pendingCount = fPendingPackages.size(); - text << pendingCount; - if (pendingCount > 1) - text << B_TRANSLATE(" packages to download"); - else - text << B_TRANSLATE(" package to download"); + static BStringFormat format(B_TRANSLATE("{0, plural," + "one{1 package to download}" + "other{# packages to download}}")); + format.Format(text, fPendingPackages.size()); + SetText(text); } @@ -157,12 +157,15 @@ WorkStatusView::_SetTextPendingDownloads() void WorkStatusView::_SetTextDownloading(const BString& title) { - BString text(B_TRANSLATE("Downloading package ")); - text << title; + BString text(B_TRANSLATE("Downloading package '%name%'")); + text.ReplaceFirst("%name%", title); + if (!fPendingPackages.empty()) { - text << " ("; - text << fPendingPackages.size(); - text << B_TRANSLATE(" more to download)"); + BString count; + cout << fPendingPackages.size(); + BString more(B_TRANSLATE("(%count% more to download)")); + more.ReplaceFirst("%count%", count); + text += more; } SetText(text); } diff --git a/src/kits/media/Jamfile b/src/kits/media/Jamfile index 5c86a124dc..beb0781f86 100644 --- a/src/kits/media/Jamfile +++ b/src/kits/media/Jamfile @@ -103,3 +103,9 @@ for architectureObject in [ MultiArchSubDirSetup ] { ; } } + +DoCatalogs libbe.so + : x-vnd.Haiku-libmedia + : + MediaDefs.cpp + ; diff --git a/src/preferences/keymap/KeyboardLayoutView.cpp b/src/preferences/keymap/KeyboardLayoutView.cpp index 74e901abb8..3b7234f226 100644 --- a/src/preferences/keymap/KeyboardLayoutView.cpp +++ b/src/preferences/keymap/KeyboardLayoutView.cpp @@ -934,26 +934,41 @@ const char* KeyboardLayoutView::_SpecialKeyLabel(const key_map& map, uint32 code, bool abbreviated) { - if (code == map.caps_key) - return abbreviated ? "CAPS" : "CAPS LOCK"; + if (code == map.caps_key) { + return abbreviated + ? B_TRANSLATE_COMMENT("CAPS", "Very short for 'caps lock'") + : B_TRANSLATE("CAPS LOCK"); + } if (code == map.scroll_key) - return "SCROLL"; - if (code == map.num_key) - return abbreviated ? "NUM" : "NUM LOCK"; + return B_TRANSLATE("SCROLL"); + if (code == map.num_key) { + return abbreviated + ? B_TRANSLATE_COMMENT("NUM", "Very short for 'num lock'") + : B_TRANSLATE("NUM LOCK"); + } if (code == map.left_shift_key || code == map.right_shift_key) - return "SHIFT"; - if (code == map.left_command_key || code == map.right_command_key) - return abbreviated ? "CMD" : "COMMAND"; - if (code == map.left_control_key || code == map.right_control_key) - return abbreviated ? "CTRL" : "CONTROL"; - if (code == map.left_option_key || code == map.right_option_key) - return abbreviated ? "OPT" : "OPTION"; + return B_TRANSLATE("SHIFT"); + if (code == map.left_command_key || code == map.right_command_key) { + return abbreviated + ? B_TRANSLATE_COMMENT("CMD", "Very short for 'command'") + : B_TRANSLATE("COMMAND"); + } + if (code == map.left_control_key || code == map.right_control_key) { + return abbreviated + ? B_TRANSLATE_COMMENT("CTRL", "Very short for 'control'") + : B_TRANSLATE("CONTROL"); + } + if (code == map.left_option_key || code == map.right_option_key) { + return abbreviated + ? B_TRANSLATE_COMMENT("OPT", "Very short for 'option'") + : B_TRANSLATE("OPTION"); + } if (code == map.menu_key) - return "MENU"; + return B_TRANSLATE("MENU"); if (code == B_PRINT_KEY) - return "PRINT"; + return B_TRANSLATE("PRINT"); if (code == B_PAUSE_KEY) - return "PAUSE"; + return B_TRANSLATE("PAUSE"); return NULL; } @@ -991,22 +1006,28 @@ KeyboardLayoutView::_SpecialMappedKeyLabel(const char* bytes, size_t numBytes, { if (numBytes != 1) return NULL; - if (bytes[0] == B_ESCAPE) - return "ESC"; - + return B_TRANSLATE("ESC"); if (bytes[0] == B_INSERT) - return "INS"; + return B_TRANSLATE("INS"); if (bytes[0] == B_DELETE) - return "DEL"; + return B_TRANSLATE("DEL"); if (bytes[0] == B_HOME) - return "HOME"; + return B_TRANSLATE("HOME"); if (bytes[0] == B_END) - return "END"; - if (bytes[0] == B_PAGE_UP) - return abbreviated ? "PG \xe2\x86\x91" : "PAGE \xe2\x86\x91"; - if (bytes[0] == B_PAGE_DOWN) - return abbreviated ? "PG \xe2\x86\x93" : "PAGE \xe2\x86\x93"; + return B_TRANSLATE("END"); + if (bytes[0] == B_PAGE_UP) { + return abbreviated + ? B_TRANSLATE_COMMENT("PG \xe2\x86\x91", + "Very short for 'page up'") + : B_TRANSLATE("PAGE \xe2\x86\x91"); + } + if (bytes[0] == B_PAGE_DOWN) { + return abbreviated + ? B_TRANSLATE_COMMENT("PG \xe2\x86\x93", + "Very short for 'page down'") + : B_TRANSLATE("PAGE \xe2\x86\x93"); + } return NULL; } diff --git a/src/preferences/media/MediaViews.cpp b/src/preferences/media/MediaViews.cpp index 61d3a9c45b..c0e2f785ed 100644 --- a/src/preferences/media/MediaViews.cpp +++ b/src/preferences/media/MediaViews.cpp @@ -48,11 +48,13 @@ SettingsView::SettingsView() fOutputMenu(NULL) { // input menu - fInputMenu = new BPopUpMenu(B_TRANSLATE("")); + fInputMenu = new BPopUpMenu(B_TRANSLATE_ALL("", + "VideoInputMenu", "Used when no video input is available")); fInputMenu->SetLabelFromMarked(true); - // input menu - fOutputMenu = new BPopUpMenu(B_TRANSLATE("")); + // output menu + fOutputMenu = new BPopUpMenu(B_TRANSLATE_ALL("", + "VideoOutputMenu", "Used when no video output is available")); fOutputMenu->SetLabelFromMarked(true); } diff --git a/src/preferences/media/MidiSettingsView.cpp b/src/preferences/media/MidiSettingsView.cpp index c1a3209070..aa6a2d367c 100644 --- a/src/preferences/media/MidiSettingsView.cpp +++ b/src/preferences/media/MidiSettingsView.cpp @@ -256,7 +256,7 @@ MidiSettingsView::_UpdateSoundFontStatus() { if (fListView->IsEmpty()) { fSoundFontStatus->SetText( - B_TRANSLATE("There are no SoundFont installed.")); + B_TRANSLATE("There are no SoundFonts installed.")); return; } int32 selection = fListView->CurrentSelection(); diff --git a/src/preferences/network/InterfaceView.cpp b/src/preferences/network/InterfaceView.cpp index 71e7c6901b..c9309110a6 100644 --- a/src/preferences/network/InterfaceView.cpp +++ b/src/preferences/network/InterfaceView.cpp @@ -313,7 +313,8 @@ InterfaceView::_Update(bool updateWirelessNetworks) } //fRenegotiateButton->SetEnabled(!disabled); - fToggleButton->SetLabel(disabled ? "Enable" : "Disable"); + fToggleButton->SetLabel(disabled + ? B_TRANSLATE("Enable") : B_TRANSLATE("Disable")); return B_OK; } diff --git a/src/preferences/network/ServiceListItem.cpp b/src/preferences/network/ServiceListItem.cpp index 604fe434f3..e3b90bcf51 100644 --- a/src/preferences/network/ServiceListItem.cpp +++ b/src/preferences/network/ServiceListItem.cpp @@ -13,14 +13,14 @@ #include -static const char* kEnabledState = "on"; -static const char* kDisabledState = "off"; - - #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "ServiceListItem" +static const char* kEnabledState = B_TRANSLATE_MARK("on"); +static const char* kDisabledState = B_TRANSLATE_MARK("off"); + + ServiceListItem::ServiceListItem(const char* name, const char* label, const BNetworkSettings& settings) : diff --git a/src/preferences/repositories/Jamfile b/src/preferences/repositories/Jamfile index af8243b745..0b92d80ccb 100644 --- a/src/preferences/repositories/Jamfile +++ b/src/preferences/repositories/Jamfile @@ -23,6 +23,7 @@ DoCatalogs Repositories : : AddRepoWindow.cpp constants.h + RepoRow.cpp Repositories.cpp RepositoriesView.cpp RepositoriesWindow.cpp diff --git a/src/preferences/repositories/RepoRow.cpp b/src/preferences/repositories/RepoRow.cpp index 328f64c975..6184fd1b9f 100644 --- a/src/preferences/repositories/RepoRow.cpp +++ b/src/preferences/repositories/RepoRow.cpp @@ -9,11 +9,16 @@ #include "RepoRow.h" +#include #include #include "constants.h" +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "RepoRow" + + RepoRow::RepoRow(const char* repo_name, const char* repo_url, bool enabled) : BRow(), @@ -53,7 +58,8 @@ RepoRow::RefreshEnabledField() { BStringField* field = (BStringField*)GetField(kEnabledColumn); if (fTaskState == STATE_NOT_IN_QUEUE) - field->SetString(fEnabled ? B_TRANSLATE("Enabled") : ""); + field->SetString(fEnabled ? B_TRANSLATE_COMMENT("Enabled", + "Tag in the Status column") : ""); else field->SetString(B_UTF8_ELLIPSIS); Invalidate(); diff --git a/src/preferences/shortcuts/ShortcutsSpec.cpp b/src/preferences/shortcuts/ShortcutsSpec.cpp index 3bb63e2263..edc058e3c3 100644 --- a/src/preferences/shortcuts/ShortcutsSpec.cpp +++ b/src/preferences/shortcuts/ShortcutsSpec.cpp @@ -75,20 +75,20 @@ SetupStandardMap(MetaKeyStateMap& map, const char* name, uint32 both, map.SetInfo(name); // In this state, neither key may be pressed. - map.AddState("(None)", new HasBitsFieldTester(0, both)); + map.AddState(B_TRANSLATE("(None)"), new HasBitsFieldTester(0, both)); // Here, either may be pressed. (Remember both is NOT a 2-bit chord, it's // another bit entirely) - map.AddState("Either", new HasBitsFieldTester(both)); + map.AddState(B_TRANSLATE("Either"), new HasBitsFieldTester(both)); // Here, only the left may be pressed - map.AddState("Left", new HasBitsFieldTester(left, right)); + map.AddState(B_TRANSLATE("Left"), new HasBitsFieldTester(left, right)); // Here, only the right may be pressed - map.AddState("Right", new HasBitsFieldTester(right, left)); + map.AddState(B_TRANSLATE("Right"), new HasBitsFieldTester(right, left)); // Here, both must be pressed. - map.AddState("Both", new HasBitsFieldTester(left | right)); + map.AddState(B_TRANSLATE("Both"), new HasBitsFieldTester(left | right)); } diff --git a/src/servers/bluetooth/DeskbarReplicant.cpp b/src/servers/bluetooth/DeskbarReplicant.cpp index a81a953581..ea4881c346 100644 --- a/src/servers/bluetooth/DeskbarReplicant.cpp +++ b/src/servers/bluetooth/DeskbarReplicant.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,11 @@ const uint32 kMsgQuitBluetoothServer = 'qbts'; const char* kDeskbarItemName = "BluetoothServerReplicant"; const char* kClassName = "DeskbarReplicant"; + +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "BluetoothReplicant" + + // #pragma mark - @@ -167,12 +173,12 @@ DeskbarReplicant::MouseDown(BPoint where) BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING, false, false); - menu->AddItem(new BMenuItem("Settings" B_UTF8_ELLIPSIS, + menu->AddItem(new BMenuItem(B_TRANSLATE("Settings" B_UTF8_ELLIPSIS), new BMessage(kMsgOpenBluetoothPreferences))); // TODO show list of known/paired devices - menu->AddItem(new BMenuItem("Quit", + menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(kMsgQuitBluetoothServer))); menu->SetTargetForItems(this); @@ -194,7 +200,8 @@ DeskbarReplicant::_QuitBluetoothServer() status_t status = BMessenger(BLUETOOTH_SIGNATURE).SendMessage( B_QUIT_REQUESTED); if (status < B_OK) { - _ShowErrorAlert("Stopping the Bluetooth server failed.", status); + _ShowErrorAlert(B_TRANSLATE("Stopping the Bluetooth server failed."), + status); } } @@ -202,8 +209,11 @@ DeskbarReplicant::_QuitBluetoothServer() void DeskbarReplicant::_ShowErrorAlert(BString msg, status_t status) { - msg << "\n\nError: " << strerror(status); - BAlert* alert = new BAlert("Bluetooth error", msg.String(), "OK"); + BString error = B_TRANSLATE("Error: %status%"); + error.ReplaceFirst("%status%", strerror(status)); + msg << "\n\n" << error; + BAlert* alert = new BAlert(B_TRANSLATE("Bluetooth error"), msg.String(), + B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); } diff --git a/src/servers/bluetooth/Jamfile b/src/servers/bluetooth/Jamfile index 5270a1ae2f..eff268b36c 100644 --- a/src/servers/bluetooth/Jamfile +++ b/src/servers/bluetooth/Jamfile @@ -15,6 +15,12 @@ Server bluetooth_server HCITransportAccessor.cpp LocalDeviceHandler.cpp LocalDeviceImpl.cpp - : be network libbluetooth.so + : be network libbluetooth.so localestub [ TargetLibstdc++ ] ; + +DoCatalogs bluetooth_server : + x-vnd.Haiku-bluetooth_server + : + DeskbarReplicant.cpp +;