Skip to content

Can you use variables in translated strings? #261

Answered by MyreMylar
Timo654 asked this question in Q&A
Discussion options

You must be logged in to vote

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 the set_text() function. These are then passed through to the translate function so the interface would be something like:

Code:

test_label = pygame_gui.elements.UILabel(pygame.Rect((10, 100), (150, 30)),
          …

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@Timo654
Comment options

Comment options

You must be logged in to vote
1 reply
@Timo654
Comment options

Answer selected by Timo654
Comment options

You must be logged in to vote
3 replies
@Timo654
Comment options

@MyreMylar
Comment options

@Timo654
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants