Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
Adds support for marking core strings for translation, and sets Qt up to parse them (e.g. OSD messages).
Adds language selection to Qt.
As an aside, I'm a bit sad that lupdate seems to ignore aliased functions with incorrect numbers of parameters. I originally had a
TRANSLATE_FMT
helper which forwarded the result to translate/fmt automatically.. instead we have to make do withfmt::format(TRANSLATE_SV(...
.Documentation:
To mark a string for translation:
TRANSLATE(context, message)
for a C string.TRANSLATE_SV(context, message)
to get astd::string_view
back.TRANSLATE_FMT(context, message)
to get astd::string
back.TRANSLATE_NOOP(context, message)
.fmt::format(TRANSLATE_SV("USB", "{} set to {}.", x, y))
, writefmt::format(TRANSLATE_SV("USB", "{0} set to {1}.", x, y))
. Not all languages follow the same word ordering.tr()
andqApp->translate()
.I've wrote a simple-ish caching system for message to avoid runtime string allocation, mainly for when I mark the big picture UI as translatable later. I'll probably do a compile-time string hashing system on top of that, to make lookups faster, but for now this'll do.
For ImGui, the glyph ranges used by your language need to be extracted. There's a Python script under translations which should be run after pulling in .ts file updates.
To add a new language:
QtHost::GetAvailableLanguageList()
. Preferably using the native title for the language. The second part of the pair should match the two-letter country code, or with the region hyphenated.CMakeLists.txt
underTS_FILES
. You must add it.Translations.cpp
.Rationale behind Changes
One step closer to 2.0 release.
Suggested Testing Steps
Make sure pad and USB configuration still works.
Make sure OSD messages aren't broken.