Merge pull request #4986 from lemondrops/patch-2

Localization fixes
This commit is contained in:
Miran Grča
2024-11-21 23:54:36 +01:00
committed by GitHub
4 changed files with 2182 additions and 36 deletions

View File

@@ -455,46 +455,52 @@ if (UNIX AND NOT APPLE AND NOT HAIKU)
endif()
endif()
# Get the Qt translations directory
get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_MAJOR}::qmake IMPORTED_LOCATION)
execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_TRANSLATIONS OUTPUT_VARIABLE QT_TRANSLATIONS_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
option(EMBED_QTBASE_TRANSLATIONS "Embed the base Qt translations into the executable" ON)
if (EMBED_QTBASE_TRANSLATIONS)
# Get the Qt translations directory
get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_MAJOR}::qmake IMPORTED_LOCATION)
execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_TRANSLATIONS OUTPUT_VARIABLE QT_TRANSLATIONS_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
set(QM_FILES)
file(GLOB po_files "${CMAKE_CURRENT_SOURCE_DIR}/languages/*.po")
foreach(po_file ${po_files})
get_filename_component(PO_FILE_NAME ${po_file} NAME_WE)
# Get the language and country
string(REGEX MATCH "^[a-z]+" PO_LANGUAGE ${PO_FILE_NAME})
string(REGEX MATCH "[A-Z]+$" PO_COUNTRY ${PO_FILE_NAME})
if (EMBED_QTBASE_TRANSLATIONS)
# Get the language and country
string(REGEX MATCH "^[a-z]+" PO_LANGUAGE ${PO_FILE_NAME})
string(REGEX MATCH "[A-Z]+$" PO_COUNTRY ${PO_FILE_NAME})
# Find the base Qt translation for the language and country
set(qt_translation_file_dest "qt_${PO_LANGUAGE}_${PO_COUNTRY}.qm")
if (EXISTS "${QT_TRANSLATIONS_DIR}/qtbase_${PO_LANGUAGE}_${PO_COUNTRY}.qm")
set(qt_translation_file "qtbase_${PO_LANGUAGE}_${PO_COUNTRY}.qm")
# Fall back to just the language if country isn't found
elseif (EXISTS "${QT_TRANSLATIONS_DIR}/qtbase_${PO_LANGUAGE}.qm")
set(qt_translation_file "qtbase_${PO_LANGUAGE}.qm")
# If the translation is still not found, try the legacy Qt one
elseif (EXISTS "${QT_TRANSLATIONS_DIR}/qt_${PO_LANGUAGE}_${PO_COUNTRY}.qm")
set(qt_translation_file "qt_${PO_LANGUAGE}_${PO_COUNTRY}.qm")
# Fall back to just the language again
elseif (EXISTS "${QT_TRANSLATIONS_DIR}/qt_${PO_LANGUAGE}.qm")
set(qt_translation_file "qt_${PO_LANGUAGE}.qm")
else()
unset(qt_translation_file)
endif()
# Copy the translation file to the build directory
if (qt_translation_file)
file(COPY "${QT_TRANSLATIONS_DIR}/${qt_translation_file}" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
if (NOT (qt_translation_file STREQUAL qt_translation_file_dest))
# Rename the file for consistency
file(RENAME "${CMAKE_CURRENT_BINARY_DIR}/${qt_translation_file}" "${CMAKE_CURRENT_BINARY_DIR}/${qt_translation_file_dest}")
# Find the base Qt translation for the language and country
set(qt_translation_file_dest "qt_${PO_LANGUAGE}_${PO_COUNTRY}.qm")
if (EXISTS "${QT_TRANSLATIONS_DIR}/qtbase_${PO_LANGUAGE}_${PO_COUNTRY}.qm")
set(qt_translation_file "qtbase_${PO_LANGUAGE}_${PO_COUNTRY}.qm")
# Fall back to just the language if country isn't found
elseif (EXISTS "${QT_TRANSLATIONS_DIR}/qtbase_${PO_LANGUAGE}.qm")
set(qt_translation_file "qtbase_${PO_LANGUAGE}.qm")
# If the translation is still not found, try the legacy Qt one
elseif (EXISTS "${QT_TRANSLATIONS_DIR}/qt_${PO_LANGUAGE}_${PO_COUNTRY}.qm")
set(qt_translation_file "qt_${PO_LANGUAGE}_${PO_COUNTRY}.qm")
# Fall back to just the language again
elseif (EXISTS "${QT_TRANSLATIONS_DIR}/qt_${PO_LANGUAGE}.qm")
set(qt_translation_file "qt_${PO_LANGUAGE}.qm")
else()
unset(qt_translation_file)
endif()
# Copy the translation file to the build directory
if (qt_translation_file)
file(COPY "${QT_TRANSLATIONS_DIR}/${qt_translation_file}" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
if (NOT (qt_translation_file STREQUAL qt_translation_file_dest))
# Rename the file for consistency
file(RENAME "${CMAKE_CURRENT_BINARY_DIR}/${qt_translation_file}" "${CMAKE_CURRENT_BINARY_DIR}/${qt_translation_file_dest}")
endif()
# Add the file to the translations list
string(APPEND QT_TRANSLATIONS_LIST " <file>${qt_translation_file_dest}</file>\n")
list(APPEND QM_FILES "${CMAKE_CURRENT_BINARY_DIR}/${qt_translation_file_dest}")
endif()
# Add the file to the translations list
string(APPEND QT_TRANSLATIONS_LIST " <file>${qt_translation_file_dest}</file>\n")
list(APPEND QM_FILES "${CMAKE_CURRENT_BINARY_DIR}/${qt_translation_file_dest}")
endif()
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/86box_${PO_FILE_NAME}.qm"

2134
src/qt/languages/86box.pot Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1282,10 +1282,10 @@ msgid "Host CD/DVD Drive (%1)"
msgstr "Главный CD/DVD-привод (%1)"
msgid "Unknown Bus"
msgstr "Неизвестный автобус"
msgstr "Неизвестная шина"
msgid "Null Driver"
msgstr "Нулевой водитель"
msgstr "Нулевой драйвер"
msgid "NIC %02i (%ls) %ls"
msgstr "NIC %02i (%ls) %ls"
@@ -2126,3 +2126,9 @@ msgstr "30 Гц (JMP2 = 1)"
msgid "60 Hz (JMP2 = 2)"
msgstr "60 Гц (JMP2 = 2)"
msgid "Generic PC/XT Memory Expansion"
msgstr "Стандартное расширение памяти PC/XT"
msgid "Generic PC/AT Memory Expansion"
msgstr "Стандартное расширение памяти PC/AT"

View File

@@ -99,7 +99,7 @@ addRow(QAbstractItemModel *model, hard_disk_t *hd)
model->setData(model->index(row, ColumnHeads), hd->hpc);
model->setData(model->index(row, ColumnSectors), hd->spt);
model->setData(model->index(row, ColumnSize), (hd->tracks * hd->hpc * hd->spt) >> 11);
model->setData(model->index(row, ColumnSpeed), hdd_preset_getname(hd->speed_preset));
model->setData(model->index(row, ColumnSpeed), QObject::tr(hdd_preset_getname(hd->speed_preset)));
model->setData(model->index(row, ColumnSpeed), hd->speed_preset, Qt::UserRole);
}
@@ -267,7 +267,7 @@ SettingsHarddisks::on_comboBoxSpeed_currentIndexChanged(int index)
auto *model = ui->tableView->model();
auto col = idx.siblingAtColumn(ColumnSpeed);
model->setData(col, ui->comboBoxSpeed->currentData(Qt::UserRole), Qt::UserRole);
model->setData(col, hdd_preset_getname(ui->comboBoxSpeed->currentData(Qt::UserRole).toUInt()));
model->setData(col, QObject::tr(hdd_preset_getname(ui->comboBoxSpeed->currentData(Qt::UserRole).toUInt())));
}
}