Buttons don't always shrink to fit text when using translations.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Void

For some reason, buttons don’t always seem to shrink to fit the text when using translations. Some buttons do, others don’t, and I can’t find any correlation between them.

For example, on the main menu scene there’s this:

Main scene

While on the UI scene, there’s this:

UI scene

The UI scene is then instanced into the main menu scene at runtime, and the result is this:

The game running

As you can see, the options button shrinks to fit the translation, but the new game/load game buttons don’t. The same thing happens in other scenes, so it isn’t an issue with instancing the UI.

I’ve also tried looking at the tscn files myself, and I see absolutely nothing different. In addition, copy-pasting the button from one tscn into another causes it to work, but doing more-or-less anything with it (moving it or connecting a signal) causes it to return to not shrink properly.

Am I doing something wrong? I’ve been at this for hours but haven’t found anything.

:bust_in_silhouette: Reply From: Poobslag

It sounds like some people accomplish this by nesting each individual button in their own “CenterContainer” or “MarginContainer” which is responsible for their layout.

Unfortunately, it does not seem like Godot has any native solution for the “translation keys are very wide” problem. You have to roll your own by nesting your components in strange ways, or using an alternative solution such as GetText.