Skip to content

Make strings translatable#111

Open
Jojo-Schmitz wants to merge 1 commit into
musescore:mainfrom
Jojo-Schmitz:translatable
Open

Make strings translatable#111
Jojo-Schmitz wants to merge 1 commit into
musescore:mainfrom
Jojo-Schmitz:translatable

Conversation

@Jojo-Schmitz

Copy link
Copy Markdown
Contributor

Resolves: #110

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 304e8715-83a3-4fd7-887a-35bd021ac6c8

📥 Commits

Reviewing files that changed from the base of the PR and between 925c23c and 0c1c1a8.

📒 Files selected for processing (1)
  • framework/global/serialization/xmlstreamreader.cpp

📝 Walkthrough

Walkthrough

In xmlstreamreader.cpp, translation.h is added and the empty-document and unknown-encoding error strings in setData() are replaced with mtrc(...) calls. Public interfaces and error propagation remain unchanged.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete and only references the issue number, missing the required summary, motivation, and checklist items. Add the missing short change summary, motivation, and completed checklist items required by the template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: making strings translatable.
Linked Issues check ✅ Passed The PR makes both targeted texts translatable in xmlstreamreader.cpp, matching issue #110.
Out of Scope Changes check ✅ Passed The change set is limited to the requested translation updates and related include changes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Jojo-Schmitz Jojo-Schmitz force-pushed the translatable branch 2 times, most recently from dec7cd7 to 4081614 Compare July 3, 2026 11:11
@Jojo-Schmitz

Copy link
Copy Markdown
Contributor Author

Anything wrong on this?

m_xml->result.status = pugi::status_internal_error;
m_xml->customErr = String(u"unknown encoding");
m_xml->customErr = mtrc("global/serialization", "Unknown encoding");
LOGE() << m_xml->customErr;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that localizing internal errors of utility classes (like this one) is not the best solution.
We won't be able to figure out what the error is in the log (for example, if it's in Chinese)

It would be nice to:

  • Add or improve error codes
  • Generate error text somewhere in the business logic using the available information (e.g. "The palette configuration file is incorrect", or whatever we're reading there.)

@Jojo-Schmitz Jojo-Schmitz Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't as internal as you'd think: I've see it in the UI, in a MuseScore dialog, see #110

BTW: any idea why the unit test fails?

@igorkorsukov igorkorsukov Jul 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't as internal as you'd think: I've see it in the UI, in a MuseScore dialog, see #110

We need to fix these places - make a message based on the error code.
And not display a message from the utility class. That's the same as if we were displaying an error from QXmlStreamReader::errorString

BTW: any idea why the unit test fails?

There was a problem with dependencies, you need to update from main

@Jojo-Schmitz Jojo-Schmitz Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Problem with that: it (XmlStreamReader::setData()) seems to be called via a constructor (XmlStreamReader::XmlStreamReader), not directly, not in this case at least (it is not a MusicXML import nor about a palette, nor a Mu2 score), but on reading a .mscz file which contained binary junk only.
  • OK, rebasing now. Edit: doesn't help

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do this:

        m_xml->customErr = mtrc("global/serialization", "Empty document");
        LOGE() << "Empty document");

Have it translated in the UI and untranslated in the logs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to make the error text in the business logic rather than in the utility class, because:

  • We can change the implementation of a utility class and replace it with a third-party implementation.
  • In a specific place, a more accurate message can be making that is specific to that place.
  • The error text from the utility class is often used for internal purposes (write to the log, write somewhere...) and not for the user.
  • And it would be better to remove the log output here. An empty document isn't always an error... it depends on the context.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that's nothing I think I could do, so feel free to close this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Untranslated texts

2 participants