Skip to content

Commit

Permalink
Complain about "$" being a concatentated string
Browse files Browse the repository at this point in the history
Don't use "%" in our own code
  • Loading branch information
Blake-Madden committed Jan 2, 2025
1 parent 93bba14 commit 9937047
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ set(FILES ../src/analyze.cpp ../src/gui/i18napp.cpp ../src/gui/projectdlg.cpp ..
../src/translation_catalog_review.cpp ../src/rc_file_review.cpp ../src/gui/insert_transmacro_dlg.cpp
../src/gui/insert_translator_comment_dlg.cpp ../src/gui/convert_string_dlg.cpp
../src/gui/insert_warning_suppression_dlg.cpp
../src/info_plist_review.cpp
../src/pseudo_translate.cpp ../src/gui/i18nframe.cpp ../src/gui/string_info_dlg.cpp)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

Expand Down
11 changes: 7 additions & 4 deletions src/i18n_review.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,8 @@ namespace i18n_check
m_localizable_strings_ambiguous_needing_context.push_back(str);
}
if ((m_review_styles & check_l10n_concatenated_strings) &&
(has_surrounding_spaces(str.m_string) || str.m_string == L"%"))
(has_surrounding_spaces(str.m_string) || str.m_string == L"%" ||
str.m_string == L"$"))
{
m_localizable_strings_being_concatenated.push_back(str);
}
Expand All @@ -1171,7 +1172,9 @@ namespace i18n_check
{
// Hard coding a percent to a number at runtime should be avoided,
// as some locales put the % at the front of the string.
if (str.m_string == L"%")
// Same with a dollar sign, where it is probably a currency string
// being pieced together.
if (str.m_string == L"%" || str.m_string == L"$")
{
m_localizable_strings_being_concatenated.push_back(str);
}
Expand Down Expand Up @@ -2893,11 +2896,11 @@ namespace i18n_check
// position will need to be zero-indexed
long position = std::wcstol(matches[1].str().c_str(), nullptr, 10) - 1;
const auto [insertionPos, inserted] = positionalCommands.insert(
std::make_pair(position, L"%" + matches[2].str()));
std::make_pair(position, std::format(L"%{}", matches[2].str())));
// if positional argument is used more than once, make sure they are consistent
if (!inserted)
{
if (insertionPos->second != L"%" + matches[2].str())
if (insertionPos->second != std::format(L"%{}", matches[2].str()))
{
#ifdef wxVERSION_NUMBER
errorInfo =
Expand Down

0 comments on commit 9937047

Please sign in to comment.