From b89314df96bd53189ebf66ae5fd3ed92da9de23e Mon Sep 17 00:00:00 2001 From: AT Date: Mon, 12 Aug 2024 11:00:49 -0400 Subject: [PATCH] Change to a whitelist for released translations. (#2830) - Change to a whitelist for released translations. - Added changelog entry. - Bump the version for translation release. Signed-off-by: Adam Treat Signed-off-by: AT Signed-off-by: Jared Van Bortel Co-authored-by: Jared Van Bortel --- gpt4all-chat/CHANGELOG.md | 1 + gpt4all-chat/CMakeLists.txt | 30 +++++++++++++----------------- gpt4all-chat/mysettings.cpp | 5 ++--- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/gpt4all-chat/CHANGELOG.md b/gpt4all-chat/CHANGELOG.md index 4084b4a0..1adeef99 100644 --- a/gpt4all-chat/CHANGELOG.md +++ b/gpt4all-chat/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Added - Add Qwen2-1.5B-Instruct to models3.json (by [@ThiloteE](https://github.com/ThiloteE) in [#2759](https://github.com/nomic-ai/gpt4all/pull/2759)) +- Enable translation feature for seven languages: English, Spanish, Italian, Portuguese, Chinese Simplified, Chinese Traditional, Romanian ([#2830](https://github.com/nomic-ai/gpt4all/pull/2830)) ### Changed - Add missing entries to Italian transltation (by [@Harvester62](https://github.com/Harvester62) in [#2783](https://github.com/nomic-ai/gpt4all/pull/2783)) diff --git a/gpt4all-chat/CMakeLists.txt b/gpt4all-chat/CMakeLists.txt index 1e59a113..79555c4f 100644 --- a/gpt4all-chat/CMakeLists.txt +++ b/gpt4all-chat/CMakeLists.txt @@ -17,10 +17,10 @@ if(APPLE) endif() set(APP_VERSION_MAJOR 3) -set(APP_VERSION_MINOR 1) -set(APP_VERSION_PATCH 2) +set(APP_VERSION_MINOR 2) +set(APP_VERSION_PATCH 0) set(APP_VERSION_BASE "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}") -set(APP_VERSION "${APP_VERSION_BASE}-dev0") +set(APP_VERSION "${APP_VERSION_BASE}") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules") @@ -32,7 +32,6 @@ project(gpt4all VERSION ${APP_VERSION_BASE} LANGUAGES CXX C) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -option(GPT4ALL_TRANSLATIONS "Build with translations" OFF) option(GPT4ALL_LOCALHOST "Build installer for localhost repo" OFF) option(GPT4ALL_OFFLINE_INSTALLER "Build an offline installer" OFF) option(GPT4ALL_SIGN_INSTALL "Sign installed binaries and installers (requires signing identities)" OFF) @@ -228,19 +227,16 @@ qt_add_qml_module(chat icons/you.svg ) -if (GPT4ALL_TRANSLATIONS) - target_compile_definitions(chat PRIVATE GPT4ALL_USE_TRANSLATIONS) - qt_add_translations(chat - TS_FILES - ${CMAKE_SOURCE_DIR}/translations/gpt4all_en_US.ts - ${CMAKE_SOURCE_DIR}/translations/gpt4all_es_MX.ts - ${CMAKE_SOURCE_DIR}/translations/gpt4all_zh_CN.ts - ${CMAKE_SOURCE_DIR}/translations/gpt4all_zh_TW.ts - ${CMAKE_SOURCE_DIR}/translations/gpt4all_ro_RO.ts - ${CMAKE_SOURCE_DIR}/translations/gpt4all_it_IT.ts - ${CMAKE_SOURCE_DIR}/translations/gpt4all_pt_BR.ts - ) -endif() +qt_add_translations(chat + TS_FILES + ${CMAKE_SOURCE_DIR}/translations/gpt4all_en_US.ts + ${CMAKE_SOURCE_DIR}/translations/gpt4all_es_MX.ts + ${CMAKE_SOURCE_DIR}/translations/gpt4all_zh_CN.ts + ${CMAKE_SOURCE_DIR}/translations/gpt4all_zh_TW.ts + ${CMAKE_SOURCE_DIR}/translations/gpt4all_ro_RO.ts + ${CMAKE_SOURCE_DIR}/translations/gpt4all_it_IT.ts + ${CMAKE_SOURCE_DIR}/translations/gpt4all_pt_BR.ts +) set_target_properties(chat PROPERTIES WIN32_EXECUTABLE TRUE diff --git a/gpt4all-chat/mysettings.cpp b/gpt4all-chat/mysettings.cpp index 5d71a661..525ccc1e 100644 --- a/gpt4all-chat/mysettings.cpp +++ b/gpt4all-chat/mysettings.cpp @@ -122,6 +122,7 @@ static QString getUiLanguage(const QString directory, const QString fileName) static QStringList getUiLanguages(const QString &modelPath) { QStringList languageList; + static const QStringList releasedLanguages = { "en_US", "it_IT", "zh_CN", "zh_TW", "es_MX", "pt_BR", "ro_RO" }; // Add the language translations from model path files first which is used by translation developers // to load translations in progress without having to rebuild all of GPT4All from source @@ -138,7 +139,7 @@ static QStringList getUiLanguages(const QString &modelPath) const QStringList qmFiles = dir.entryList({"*.qm"}, QDir::Files); for (const QString &fileName : qmFiles) { const QString lang = getUiLanguage(":/i18n", fileName); - if (!languageList.contains(lang)) + if (!languageList.contains(lang) && releasedLanguages.contains(lang)) languageList.append(lang); } } @@ -632,7 +633,6 @@ void MySettings::setLanguageAndLocale(const QString &bcp47Name) else locale = QLocale(l); -#ifdef GPT4ALL_USE_TRANSLATIONS // If we previously installed a translator, then remove it if (m_translator) { if (!qGuiApp->removeTranslator(m_translator.get())) { @@ -662,7 +662,6 @@ void MySettings::setLanguageAndLocale(const QString &bcp47Name) m_translator.reset(); } } -#endif // Finally, set the locale whether we have a translation or not QLocale::setDefault(locale);