Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing Unicode support to translation messages #248

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Add missing Unicode support to translation messages
Unicode support is required for source and comment fields because:
- Qt supports those characters in Qt Linguist files
- Languages other than English can be used for source and to comment
- Punctuation outside of the scope of Latin1 can be present in English
  E.g. Ellipsis …
Cuperino committed Mar 19, 2025
commit 56d395b84a1bfc61dd76daf83100f8ac052bd1c2
8 changes: 4 additions & 4 deletions src/core/qttsdocument.cpp
Original file line number Diff line number Diff line change
@@ -354,26 +354,26 @@ void QtTsMessage::setLine(int line)

QString QtTsMessage::comment() const
{
return QString::fromLatin1(m_message.child("comment").text().as_string());
return QString::fromUtf8(m_message.child("comment").text().as_string());
}

void QtTsMessage::setComment(const QString &comment)
{
LOG(comment);
m_message.child("comment").set_value(comment.toLatin1().constData());
m_message.child("comment").set_value(comment.toUtf8().constData());
qobject_cast<QtTsDocument *>(parent())->setHasChanged(true);
Q_EMIT commentChanged();
}

QString QtTsMessage::source() const
{
return QString::fromLatin1(m_message.child("source").text().as_string());
return QString::fromUtf8(m_message.child("source").text().as_string());
}

void QtTsMessage::setSource(const QString &source)
{
LOG(source);
m_message.child("source").set_value(source.toLatin1().constData());
m_message.child("source").set_value(source.toUtf8().constData());
qobject_cast<QtTsDocument *>(parent())->setHasChanged(true);
Q_EMIT sourceChanged();
}