-
-
Notifications
You must be signed in to change notification settings - Fork 451
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
Use fmt::format instead of SString constructor for string formatting #1804
Conversation
Might cause an issue with localization |
And how could they be solved? Edit: Searched it up on google, and found this: fmtlib/fmt#305 . Interestingly the doc doesnt say anything about 'n' |
Client/core/CConnectManager.cpp
Outdated
SString strBuffer(_("Connecting to %s at port %u failed!"), m_strHost.c_str(), m_usPort); | ||
SString strBuffer(_("Connecting to {} at port {} failed!"), m_strHost, m_usPort); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strings inside _() are matched and replaced depending on the selected language. e.g. "Connecting to %s at port %u failed!" is replaced with "تعذر الإتصال بـ %s في المنفذ %u!" when Arabic is selected. Changing the content of the original string will make the match fail, and probably flag the string as requiring a new translation at https://translate.mtasa.com/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this was done by a script, and I didnt verify it yet. (Forgot to mark the PR as draft).
I'll correct this, thanks!
Edit: Can I edit the .po
files myself, to make it work? Eg.: Replace Connecting to %s at port %u failed!
with Connecting to {} at port {} failed!
in the .po
as well.
(Reposted it, as edits dont show up on dc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I edit the
.po
files myself
The files are generated by one of the scripts here https://github.com/multitheftauto/mtasa-blue/tree/master/utils/src I think build_gettext_catalog.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with #1804 I think we should wait for c++20 instead of adding another dependency.
Especially hopping from SString to fmt::format to std::string seems like a lot of unnecessary mass changes.
ca720cf
to
85ac059
Compare
37f715a
to
e1bfe90
Compare
"Set cppdialect to C++20 #1803" has been closed in favour of just waiting for C++20 to release. Going to close this too. |
Replace all SString consructors that are used for string formatting to
fmt::format
.Replace SString ctors that are used for number -> string conversion with std::to_string.
Todo:
fmt::format
as well.I've made a python script (250-300 lines, terrible code), that did all this for me, thankfully.