Simplify strings for PaletteEditor command removing leading blanks

This issue was brought up here:
https://github.com/aseprite/aseprite/pull/4207#issuecomment-1845334373
This commit is contained in:
David Capello 2023-12-07 12:11:00 -03:00
parent f7c830d984
commit 84187ad1ec
3 changed files with 15 additions and 7 deletions

View File

@ -368,11 +368,11 @@ OpenInFolder = Open In Folder
OpenScriptFolder = Open Script Folder
OpenWithApp = Open With Associated Application
Options = Preferences
PaletteEditor = Switch{0}{1}{2}
PaletteEditor_Edit = \ Edit Palette Mode
PaletteEditor_And = \ and
PaletteEditor_FgPopup = \ Foreground Color Popup
PaletteEditor_BgPopup = \ Background Color Popup
PaletteEditor = Switch {0} {1} {2}
PaletteEditor_Edit = Edit Palette Mode
PaletteEditor_And = and
PaletteEditor_FgPopup = Foreground Color Popup
PaletteEditor_BgPopup = Background Color Popup
PaletteSize = Palette Size
Paste = Paste
PasteText = Insert Text

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2023 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
@ -12,6 +13,8 @@
#include "app/commands/params.h"
#include "app/i18n/strings.h"
#include "app/ui/color_bar.h"
#include "base/replace_string.h"
#include "base/trim_string.h"
#include "fmt/format.h"
namespace app {
@ -103,7 +106,13 @@ std::string PaletteEditorCommand::onGetFriendlyName() const
else
popup = Strings::commands_PaletteEditor_FgPopup();
}
return fmt::format(getBaseFriendlyName(), edit, plus, popup);
std::string result = fmt::format(getBaseFriendlyName(), edit, plus, popup);
// TODO create a new function to remove duplicate whitespaces
base::replace_string(result, " ", " ");
base::replace_string(result, " ", " ");
base::trim_string(result, result);
return result;
}
Command* CommandFactory::createPaletteEditorCommand()

View File

@ -162,7 +162,6 @@ void Strings::loadStringsFromFile(const std::string& fn)
value = cfg.getValue(section.c_str(), key.c_str(), "");
base::replace_string(value, "\\n", "\n");
base::replace_string(value, "\\ ", " "); // Mainly used for leading blanks
m_strings[textId] = value;
//TRACE("I18N: Reading string %s -> %s\n", textId.c_str(), m_strings[textId].c_str());