[solved] Changing Field Labels in Gravity Forms with gform_pre_render

I have taken on a wordpress project recently which required me to change the language of the text in the field labels on some gravity forms.

The site is in one language, but within wordpress they have the option to show certain pages in a different language, for example Norwegian.

So, if we have a form with the default text of Name and Telephone and the form was being shown on a Norwegian page, then the text would need to display: Navn and Telefon.

On the left is the form with the english texts and on the right is the form when the setting of the page is set to Norwegian.

gform_pre_render

The guys at Gravity Help showed me this page: https://www.gravityhelp.com/documentation/article/gform_pre_render/ which is slightly too advanced for what I wanted to do because all I need to do is change the words in the gfield_label within the form.

In the end, I came up with this solution below which works perfectly: