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 :)

asked Apr 3, 2018 in Engine by Mezkino (23 points)

2 Answers

–1 vote

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 :)

answered Apr 4, 2018 by Mezkino (23 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 {
    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.

answered Jun 15 by JimArtificer (699 points)
edited Jun 15 by JimArtificer
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.