#Getting the key of a table entry in Localization Package
1 messages ยท Page 1 of 1 (latest)
This feels like an XY-Problem. What do you need to know the key for?
As I gave in the example, I want to obtain the key as a string. For example "U_Skillseet69cha..."
I did understand your question.
What I am wondering is why you need to obtain the key.
And also, with what information are you trying to get said key?
Do you need a list of all keys inside a given table?
Are you trying to make a sort of reverse lookup of table entries where you feed it a value and it gives a key?
Something else?
For an example. I have a LocalizedString variable. How can i get this variable's key name as a string via code. What I'm about to do is check if its starts with the letter "U".
Okay, that answers what you want to do with the key. But why do you want to check the key, specifically?
According to this forum post, you can obtain the key of a given LocalizedString using cs var tableEntry = LocalizationSettings.StringDatabase.GetTableEntry(dialogueLocalizedRef.TableReference, dialogueLocalizedRef.TableEntryReference); var key = tableEntry.Entry.SharedEntry.Key;
However, since your purpose is to evaluate the key, I strongly urge you to use metadata instead.
If you click the {๐} button above the value of your table entry, you can expand its metadata sidebar. There you can add metadata to both the individual entry, as well as the entire row (via the "Shared Entry" field).
You can either use one of the built-in metadata classes, or create your own one. and access it through ```cs
LocalizationSettings.StringDatabase.GetTableEntry(localizedString.TableReference, localizedString.TableEntryReference).Entry.GetMetadata<YourMetadataType>()
Thank you so much for your attention. I will use that ๐
@still hatch
I found another way to obtain the key name as string. It's ResolveKeyName function. But it needs a parameter called "SharedTableData". And i cant find a way to reference my LocalizedString as a parameter to this function.
If I'm reading the documentation correctly, you may be able to just pass null into ResolveKeyName.
But seriously, why are you so hell-bent on getting that key?
The purpose of the keys is to access their associated data. NOT the other way around. And it's very likely that getting the key will be a slower operation.
I know that there is probably a more proper way to handle this situation. In my condition, I'm seperating my in-game phone messages by message itselfs first letter. So i dont want to edit every single variation of texts. I just want to edit the key variable and put an "U" or "P" at the start based on which side texted this message. User or Player.