[PR #206] [CLOSED] Added Access to Qt Translation Infrastructure #243

Closed
opened 2026-05-05 11:21:32 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/qmlnet/qmlnet/pull/206
Author: @shartte
Created: 5/30/2020
Status: Closed

Base: developHead: i18n


📝 Commits (1)

  • a7ff93f Added Access to Qt Translation Infrastructure

📊 Changes

15 files changed (+555 additions, -3 deletions)

View changed files

📝 src/native/QmlNet/QmlNet.pro (+3 -0)
src/native/QmlNet/QmlNet/qml/NetTranslator.cpp (+33 -0)
src/native/QmlNet/QmlNet/qml/NetTranslator.h (+50 -0)
📝 src/native/QmlNet/QmlNet/qml/QCoreApplication.cpp (+87 -0)
📝 src/native/QmlNet/QmlNet/qml/qml.pri (+4 -2)
📝 src/native/QmlNet/QmlNetUtilities.cpp (+41 -0)
📝 src/native/QmlNet/QmlNetUtilities.h (+12 -0)
src/net/Qml.Net.Tests/QCoreApplicationTests.cs (+70 -0)
📝 src/net/Qml.Net.Tests/Qml.Net.Tests.csproj (+6 -0)
src/net/Qml.Net.Tests/Resources/example.de.qm (+0 -0)
src/net/Qml.Net.Tests/Resources/example.de.ts (+11 -0)
src/net/Qml.Net.Tests/Resources/example.de_CH.qm (+0 -0)
src/net/Qml.Net.Tests/Resources/example.de_CH.ts (+11 -0)
src/net/Qml.Net.Tests/Resources/example.ts (+11 -0)
📝 src/net/Qml.Net/QCoreApplication.cs (+216 -1)

📄 Description

This PR should fix #160 and add some additional plumbing to allow for the following:

  • Dynamic translations from C# by installing a C# function as a Qt translator (QCoreApplication.InstallTranslator, QCoreApplication.RemoveTranslator)
  • Easily load Qt Linguist translation files (QM) from disk/Qt-resources or from memory (QCoreApplication.LoadTranslationData, QCoreApplication.LoadTranslationFile)
  • Allows text to be translated using Qt's infrastructure from C# (QCoreApplication.Translate)

Some TODOs:

  • Check APIs (some require .NET Standard 2.1 right now, but might be adapted)
  • QQmlEngine::retranslate (check if this is not auto-triggered by installTranslator)
  • Add a sample
  • More tests
  • Check if unsafe may be used (is there a policy not to?) to reduce heap allocations as much as possible

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/qmlnet/qmlnet/pull/206 **Author:** [@shartte](https://github.com/shartte) **Created:** 5/30/2020 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `i18n` --- ### 📝 Commits (1) - [`a7ff93f`](https://github.com/qmlnet/qmlnet/commit/a7ff93fe2d668b63ecb1ff9bb6f86a9b578af331) Added Access to Qt Translation Infrastructure ### 📊 Changes **15 files changed** (+555 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/native/QmlNet/QmlNet.pro` (+3 -0) ➕ `src/native/QmlNet/QmlNet/qml/NetTranslator.cpp` (+33 -0) ➕ `src/native/QmlNet/QmlNet/qml/NetTranslator.h` (+50 -0) 📝 `src/native/QmlNet/QmlNet/qml/QCoreApplication.cpp` (+87 -0) 📝 `src/native/QmlNet/QmlNet/qml/qml.pri` (+4 -2) 📝 `src/native/QmlNet/QmlNetUtilities.cpp` (+41 -0) 📝 `src/native/QmlNet/QmlNetUtilities.h` (+12 -0) ➕ `src/net/Qml.Net.Tests/QCoreApplicationTests.cs` (+70 -0) 📝 `src/net/Qml.Net.Tests/Qml.Net.Tests.csproj` (+6 -0) ➕ `src/net/Qml.Net.Tests/Resources/example.de.qm` (+0 -0) ➕ `src/net/Qml.Net.Tests/Resources/example.de.ts` (+11 -0) ➕ `src/net/Qml.Net.Tests/Resources/example.de_CH.qm` (+0 -0) ➕ `src/net/Qml.Net.Tests/Resources/example.de_CH.ts` (+11 -0) ➕ `src/net/Qml.Net.Tests/Resources/example.ts` (+11 -0) 📝 `src/net/Qml.Net/QCoreApplication.cs` (+216 -1) </details> ### 📄 Description This PR should fix #160 and add some additional plumbing to allow for the following: - Dynamic translations from C# by installing a C# function as a Qt translator (QCoreApplication.InstallTranslator, QCoreApplication.RemoveTranslator) - Easily load Qt Linguist translation files (QM) from disk/Qt-resources or from memory (QCoreApplication.LoadTranslationData, QCoreApplication.LoadTranslationFile) - Allows text to be translated using Qt's infrastructure from C# (QCoreApplication.Translate) Some TODOs: - [ ] Check APIs (some require .NET Standard 2.1 right now, but might be adapted) - [ ] QQmlEngine::retranslate (check if this is not auto-triggered by installTranslator) - [ ] Add a sample - [ ] More tests - [ ] Check if unsafe may be used (is there a policy not to?) to reduce heap allocations as much as possible --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 11:21:32 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/qmlnet#243
No description provided.