0 votes

Hi there
I am using a .csv for managing my language options. Mostly I am using "labels" that are able to handle the keywords of the .csv.

But in some cases I would like to add some format to that text, so my question is if there is a way of using RichTextLabel with this keyword.

Thanks :)

in Engine by (25 points)

2 Answers

0 votes

Still, when I place a keyword from the .csv in text or in the bb_text in the editor, it is not working, but it does from code.

self.bbcode_text = tr(text)

it even recognize bb_code from the .csv :)

by (25 points)

this is still happen!

0 votes

To achieve this you will need a script to call the tr() function on the translation keyword.

One way to do this would be to attach a script that defines an exported string property that is then run through the translation function and assigned to the text field.

This is a C# example, but you should be able to convert it to GDScript pretty easily:

public class TranslatedRichTextLabel : RichTextLabel {
    [Export]
    public string TrKey; //enter your translation key in the editor

    public override void _Ready() {
        BbcodeText = Tr(TrKey);
    }
}

For simplicity you may want to write a separate script for a standard label, but you could also detect the node type to determine which text property should be assigned to.

by (856 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories