I just started using the localization package. But some things are very complicated. What I’m looking for is to localize the strings replaced by code. I don’t know what question to call this. I’ve shuffled the docs but it’s hard to understand.
I add strings to texts with tmpro text or sometimes with stringbuilder. How can I localize them? Where and how will the key be written?
simple example,
Debug.Log(“Hello”);
en=> Hello
en => Hello
de=> Hallo
fr=> Bonjour
Yes, I can do this with static (frontend) texts, but I couldn’t find how to apply it to texts added by script (eg debug.log).
example,
stringbuilder(“PERFECT”);
string txtt(“HERE”);
or
mytmpro.text(“example”);
What words should I search for this topic? please help me i don’t have much code knowledge. I can’t laqlize the texts defined in the code.
(sorry i don’t speak english. i use google translate)
this is so complicated, i don’t understand what i want to do is localize conditional texts like in every game.
For example, I may need to print “apple” by pressing A, “pear” by pressing B, and “cherry” by pressing C. Since I’m on mobile right now, I wrote this simple code textually. and their translations in different languages
How can I translate non-manually typed (scripted) strings in this way? Could you please provide a simple working code or a video tutorial link? The documents are very confusing. It is very incomprehensible to both non-English speakers and novices.
We dynamically replace the text in tmp text with code. I don’t understand how to localize it. I looked at the forum and the documentation, but I didn’t understand. Could you please give a simple example or a link to a training video? thanks
I also asked this question to the communities in my country. nobody knows.
Create a String Table and add the translations. Then access the table like so:
public class NewBehaviourScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
var hello = LocalizationSettings.StringDatabase.GetLocalizedString("My Strings", "Hello");
Debug.Log(hello);
}
}
Thanks for the quick response and help. this example took me to other places
I faced similar problems and solved it thanks to you, thanks.
In texts that change with code, accessing the object’s localization string event component and changing only the table entry key and table reference gives a more effective result. is this a good method? thanks
Hi! I know the topic is quite old, but I followed it today to add transaltions using scripts and it worked. I was wondering if there is a way to use strong typing for the two parameters here (table name and string key):
Can you give me an example of what you mean by strong typing?
The 2 structs have an implicit operator which will convert into the correct key type, this is to avoid having multiple overloads for the different ways to reference Tables and Entries. Theres no way to force one type over the other, if this is something you need then I would add another method to force the type: