-
I'm trying to translate my program and some of the text has variables in it (stuff like names and a volume slider), but I couldn't figure out how to make the variables work. Is there a way to do this? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Hello, the translation library use in pygame GUI supports this with
placeholders in translated strings. See their documentation here:
https://github.com/danhper/python-i18n#placeholder
Hopefully that helps, on my phone on the go at the moment.
…On Fri, 18 Mar 2022, 11:50 Timo654, ***@***.***> wrote:
I'm trying to translate my program and some of the text has variables in
it (stuff like names and a volume slider), but I couldn't figure out how to
make the variables work.
Is there a way to do this?
Thanks!
—
Reply to this email directly, view it on GitHub
<#261>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADGDGGV43ZAI7YRNARJXDETVARU2DANCNFSM5RBTWI3A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hello, I had a look into this and it was pretty annoying to add parameters to a UI Label's translation. I think I just used the functionality once in the File Loading/Saving dialog - but there I had complete control over what I was translating and the dialog wasn't really a plausible place to switch locale in an application. I've made a quick trial patch to the main branch (what will be 0.6.5 at some point) which adds optional kwargs to a Code:
Translation file:
If you know how to grab a repository from github and build it yourself with I'll probably roll out a 0.6.5 version over the Easter period when I have a break from work with whatever other issues have come up before that time period. |
Beta Was this translation helpful? Give feedback.
-
Thanks for testing it! I will fix that set_text() bug before release.
…On Mon, 21 Mar 2022, 08:59 Timo654, ***@***.***> wrote:
Hey,
Thanks, I just tested it. It seems to work, however when using the
set_text() function, the label will not get rebuilt.
I fixed it by adding any_changed = True after line 94 and line 96 in
pygame_gui/elements/ui_label.py.
Other than that, it seems to work fine so far.
—
Reply to this email directly, view it on GitHub
<#261 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADGDGGWLTI6TZEZAWGCYOR3VBA27HANCNFSM5RBTWI3A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I haven't had a chance to look at it yet sorry.
I should probably open an issue on the tracker to remind myself too.
…On Tue, 3 May 2022, 16:15 Timo654, ***@***.***> wrote:
Yeah, I want to double check that what I've done with the label is
sensible over the Easter break, but assuming all is well I'll extend the
same methodology to all the places where you can enter a custom string that
is passed to the translation software - like the UIMessageWindow and the
UIConfirmationDialog.
Any news on this?
—
Reply to this email directly, view it on GitHub
<#261 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADGDGGQJJZREVJIR3LCOOGLVIE7KPANCNFSM5RBTWI3A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
Hello, I had a look into this and it was pretty annoying to add parameters to a UI Label's translation. I think I just used the functionality once in the File Loading/Saving dialog - but there I had complete control over what I was translating and the dialog wasn't really a plausible place to switch locale in an application.
I've made a quick trial patch to the main branch (what will be 0.6.5 at some point) which adds optional kwargs to a
UILabel
in the constructor/init and in theset_text()
function. These are then passed through to the translate function so the interface would be something like:Code: