Skip to content

Trying to add a translator but doesn't work #779

Answered by Couldosh
Couldosh asked this question in Q&A
Discussion options

You must be logged in to vote

The trans variable was a global one, that I used to translate the errors. I discovered that the trans variable was still nil when I wanted to use it.

Why? Because this line:
trans, found := uni.GetTranslator("en")

This create a new local variable called trans, it doesn't initialize the global variable. cf:global error variable remains nil after initialization

To fix it, I did that:


var found bool
trans, found = uni.GetTranslator("en")

Replies: 1 comment

Comment options

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