Skip to content

Commit f689402

Browse files
committed
Add localization support and related files
1 parent c562418 commit f689402

16 files changed

+943
-178
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ set_target_properties(reaper_reapack PROPERTIES
112112
add_subdirectory(src)
113113
target_link_libraries(reaper_reapack reapack)
114114

115+
# Add langpack target
116+
add_executable(buildlangpack src/buildlangpack.cpp)
117+
target_include_directories(buildlangpack PRIVATE ${CMAKE_SOURCE_DIR}/vendor)
118+
target_link_libraries(buildlangpack WDL::WDL)
119+
115120
add_subdirectory(test)
116121
add_custom_target(test
117122
COMMAND $<TARGET_FILE:tests>

cmake/FindWDL.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ set(WDL_DIR "${WDL_INCLUDE_DIR}/WDL")
1414
include(FindPackageHandleStandardArgs)
1515
find_package_handle_standard_args(WDL REQUIRED_VARS WDL_DIR WDL_INCLUDE_DIR)
1616

17-
add_library(wdl ${WDL_DIR}/wingui/wndsize.cpp)
17+
add_library(wdl
18+
${WDL_DIR}/wingui/wndsize.cpp
19+
${WDL_DIR}/localize/localize.cpp
20+
)
1821

1922
target_compile_definitions(wdl INTERFACE WDL_NO_DEFINE_MINMAX)
2023
target_include_directories(wdl INTERFACE ${WDL_INCLUDE_DIR})

src/about.cpp

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#include <iomanip>
4040
#include <sstream>
4141

42+
#include <WDL/localize/localize.h>
43+
4244
enum {
4345
ACTION_ABOUT_PKG = 300, ACTION_FIND_IN_BROWSER,
4446
ACTION_COPY_URL, ACTION_LOCATE
@@ -188,11 +190,11 @@ void About::setMetadata(const Metadata *metadata, const bool substitution)
188190
}
189191

190192
if(aboutText.empty())
191-
m_desc->setPlainText("This package or repository does not provide any documentation.");
193+
m_desc->setPlainText(__LOCALIZE("This package or repository does not provide any documentation.", "reapack_about_error_msg"));
192194
else if(!m_desc->setRichText(aboutText))
193-
m_desc->setPlainText("Could not load RTF document.");
195+
m_desc->setPlainText(__LOCALIZE("Could not load RTF document.", "reapack_about_error_msg"));
194196

195-
m_tabs->addTab({"About", {m_desc->handle()}});
197+
m_tabs->addTab({__LOCALIZE("About", "reapack"), {m_desc->handle()}});
196198

197199
const auto &getLinkControl = [](const Metadata::LinkType type) {
198200
switch(type) {
@@ -292,24 +294,24 @@ void AboutIndexDelegate::init(About *dialog)
292294

293295
dialog->setTitle(m_index->name());
294296
dialog->setMetadata(m_index->metadata(), m_index->name() == "ReaPack");
295-
dialog->setAction("Install/update " + m_index->name());
297+
dialog->setAction(__LOCALIZE("Install/update ", "reapack_about_button" ) + m_index->name());
296298

297-
dialog->tabs()->addTab({"Packages",
299+
dialog->tabs()->addTab({__LOCALIZE("Packages", "reapack_about_tab"),
298300
{dialog->menu()->handle(), dialog->list()->handle()}});
299-
dialog->tabs()->addTab({"Installed Files",
301+
dialog->tabs()->addTab({__LOCALIZE("Installed Files", "reapack_about_tab"),
300302
{dialog->getControl(IDC_REPORT)}});
301303

302-
dialog->menu()->addColumn({"Category", 142});
304+
dialog->menu()->addColumn({__LOCALIZE("Category", "reapack_about_column"), 142});
303305

304306
dialog->menu()->reserveRows(m_index->categories().size() + 1);
305-
dialog->menu()->createRow()->setCell(0, "<All Packages>");
307+
dialog->menu()->createRow()->setCell(0, __LOCALIZE("<All Packages>", "reapack_about_menu"));
306308

307309
for(const Category *cat : m_index->categories())
308310
dialog->menu()->createRow()->setCell(0, cat->name());
309311

310-
dialog->list()->addColumn({"Package", 382});
311-
dialog->list()->addColumn({"Version", 80, 0, ListView::VersionType});
312-
dialog->list()->addColumn({"Author", 90});
312+
dialog->list()->addColumn({__LOCALIZE("Package", "reapack_about_column"), 382});
313+
dialog->list()->addColumn({__LOCALIZE("Version", "reapack_about_column"), 80, 0, ListView::VersionType});
314+
dialog->list()->addColumn({__LOCALIZE("Author", "reapack_about_column"), 90});
313315

314316
initInstalledFiles();
315317
}
@@ -329,9 +331,9 @@ void AboutIndexDelegate::initInstalledFiles()
329331
}
330332
catch(const reapack_error &e) {
331333
Win32::setWindowText(report, String::format(
332-
"The file list is currently unavailable.\x20"
334+
__LOCALIZE("The file list is currently unavailable.\x20"
333335
"Retry later when all installation task are completed.\r\n"
334-
"\r\nError description: %s", e.what()
336+
"\r\nError description: %s", "reapack_about_error_msg"), e.what()
335337
).c_str());
336338
return;
337339
}
@@ -387,8 +389,8 @@ bool AboutIndexDelegate::fillContextMenu(Menu &menu, const int index) const
387389
if(index < 0)
388390
return false;
389391

390-
menu.addAction("Find in the &browser", ACTION_FIND_IN_BROWSER);
391-
menu.addAction("About this &package", ACTION_ABOUT_PKG);
392+
menu.addAction(__LOCALIZE("Find in the &browser", "reapack_about_menu"), ACTION_FIND_IN_BROWSER);
393+
menu.addAction(__LOCALIZE("About this &package", "reapack_about_menu"), ACTION_ABOUT_PKG);
392394

393395
return true;
394396
}
@@ -457,9 +459,9 @@ void AboutIndexDelegate::install()
457459
enum { INSTALL_ALL = 80, UPDATE_ONLY, OPEN_BROWSER };
458460

459461
Menu menu;
460-
menu.addAction("Install all packages in this repository", INSTALL_ALL);
461-
menu.addAction("Install individual packages in this repository", OPEN_BROWSER);
462-
menu.addAction("Update installed packages only", UPDATE_ONLY);
462+
menu.addAction(__LOCALIZE("Install all packages in this repository", "reapack_about_menu"), INSTALL_ALL);
463+
menu.addAction(__LOCALIZE("Install individual packages in this repository", "reapack_about_menu"), OPEN_BROWSER);
464+
menu.addAction(__LOCALIZE("Update installed packages only", "reapack_about_menu"), UPDATE_ONLY);
463465

464466
const int choice = menu.show(m_dialog->getControl(IDC_ACTION), m_dialog->handle());
465467

@@ -471,7 +473,7 @@ void AboutIndexDelegate::install()
471473
if(!remote) {
472474
// In case the user uninstalled the repository while this dialog was opened
473475
Win32::messageBox(m_dialog->handle(),
474-
"This repository cannot be found in your current configuration.",
476+
__LOCALIZE("This repository cannot be found in your current configuration.", "reapack_about_error_msg"),
475477
"ReaPack", MB_OK);
476478
return;
477479
}
@@ -491,11 +493,11 @@ void AboutIndexDelegate::install()
491493
if(choice == INSTALL_ALL && boost::logic::indeterminate(remote.autoInstall())
492494
&& !installOpts.autoInstall) {
493495
const int btn = Win32::messageBox(m_dialog->handle(),
494-
"Do you want ReaPack to install new packages from this repository"
496+
__LOCALIZE("Do you want ReaPack to install new packages from this repository"
495497
" when synchronizing in the future?\n\nThis setting can also be"
496498
" customized globally or on a per-repository basis in"
497-
" ReaPack > Manage repositories.",
498-
"Install all packages in this repository", MB_YESNOCANCEL);
499+
" ReaPack > Manage repositories.", "reapack_about_msg"),
500+
__LOCALIZE("Install all packages in this repository", "reapack_about_msg"), MB_YESNOCANCEL);
499501

500502
switch(btn) {
501503
case IDYES:
@@ -533,16 +535,16 @@ void AboutPackageDelegate::init(About *dialog)
533535
dialog->setMetadata(m_package->metadata());
534536
dialog->setAction("About " + m_index->name());
535537

536-
dialog->tabs()->addTab({"History",
538+
dialog->tabs()->addTab({__LOCALIZE("History", "reapack_about_tab"),
537539
{dialog->menu()->handle(), dialog->getControl(IDC_CHANGELOG)}});
538-
dialog->tabs()->addTab({"Contents",
540+
dialog->tabs()->addTab({__LOCALIZE("Contents", "reapack_about_tab"),
539541
{dialog->menu()->handle(), dialog->list()->handle()}});
540542

541-
dialog->menu()->addColumn({"Version", 142, 0, ListView::VersionType});
543+
dialog->menu()->addColumn({__LOCALIZE("Version", "reapack_about_column"), 142, 0, ListView::VersionType});
542544

543-
dialog->list()->addColumn({"File", 267});
544-
dialog->list()->addColumn({"Path", 207});
545-
dialog->list()->addColumn({"Action List", 84});
545+
dialog->list()->addColumn({__LOCALIZE("File", "reapack_about_column"), 267});
546+
dialog->list()->addColumn({__LOCALIZE("Path", "reapack_about_column"), 207});
547+
dialog->list()->addColumn({__LOCALIZE("Action List", "reapack_about_column"), 84});
546548

547549
dialog->menu()->reserveRows(m_package->versions().size());
548550

@@ -562,13 +564,13 @@ void AboutPackageDelegate::init(About *dialog)
562564

563565
void AboutPackageDelegate::updateList(const int index)
564566
{
565-
constexpr std::pair<Source::Section, const char *> sectionMap[] {
566-
{Source::MainSection, "Main"},
567-
{Source::MIDIEditorSection, "MIDI Editor"},
568-
{Source::MIDIInlineEditorSection, "MIDI Inline Editor"},
569-
{Source::MIDIEventListEditorSection, "MIDI Event List Editor"},
570-
{Source::MediaExplorerSection, "Media Explorer"},
571-
{Source::CrossfadeEditorSection, "Crossfade Editor"},
567+
static const std::pair<Source::Section, const char *> sectionMap[] {
568+
{Source::MainSection, __LOCALIZE("Main", "reapack_about_source")},
569+
{Source::MIDIEditorSection, __LOCALIZE("MIDI Editor", "reapack_about_source")},
570+
{Source::MIDIInlineEditorSection, __LOCALIZE("MIDI Inline Editor", "reapack_about_source")},
571+
{Source::MIDIEventListEditorSection, __LOCALIZE("MIDI Event List Editor", "reapack_about_source")},
572+
{Source::MediaExplorerSection, __LOCALIZE("Media Explorer", "reapack_about_source")},
573+
{Source::CrossfadeEditorSection, __LOCALIZE("Crossfade Editor", "reapack_about_source")},
572574
};
573575

574576
if(index < 0)
@@ -596,14 +598,14 @@ void AboutPackageDelegate::updateList(const int index)
596598
}
597599

598600
if(sections) // In case we forgot to add a section to sectionMap!
599-
sectionNames.push_back("Other");
601+
sectionNames.push_back(__LOCALIZE("Other", "reapack_about_source"));
600602

601-
actionList = "Yes (";
603+
actionList = __LOCALIZE("Yes", "reapack") + std::string(" (");
602604
actionList += boost::algorithm::join(sectionNames, ", ");
603605
actionList += ')';
604606
}
605607
else
606-
actionList = "No";
608+
actionList = __LOCALIZE("No", "reapack");
607609

608610
int c = 0;
609611
auto row = m_dialog->list()->createRow((void *)src);
@@ -620,9 +622,9 @@ bool AboutPackageDelegate::fillContextMenu(Menu &menu, const int index) const
620622

621623
auto src = static_cast<const Source *>(m_dialog->list()->row(index)->userData);
622624

623-
menu.addAction("Copy source URL", ACTION_COPY_URL);
625+
menu.addAction(__LOCALIZE("Copy source URL", "reapack_about_menu"), ACTION_COPY_URL);
624626
menu.setEnabled(m_current.size() > 0 && FS::exists(src->targetPath()),
625-
menu.addAction("Locate in explorer/finder", ACTION_LOCATE));
627+
menu.addAction(__LOCALIZE("Locate in explorer/finder", "reapack_about_menu"), ACTION_LOCATE));
626628

627629
return true;
628630
}

0 commit comments

Comments
 (0)