Hi! Thanks a lot for answering!
I managed to work around it already. I don’t know if its optimized but it is working
What I did is:
I opened the StringTableRegistry.h to see how the macro is defined. It is defined to this:
/** Creates and registers a new string table instance, loading strings from the given file (the path is relative to the game content directory). */
#define LOCTABLE_FROMFILE_GAME(ID, NAMESPACE, FILEPATH) \
FStringTableRegistry::Get().Internal_LocTableFromFile(TEXT(ID), TEXT(NAMESPACE), TEXT(FILEPATH), FPaths::ProjectContentDir())
(It already has the TEXT() within its definition).
So instead of using the macro, I used the FStringTableRegistry::Get().Internal_LocTableFromFile() function. Instead of the TEXT() macro, I used the TCHAR_TO_UTF8() macro. Like this:
Thanks a lot for answering to help me. I’m still getting the hang with UE4’s macros, variables, functions…
I’m answering my own post detailed like this just in case someone in the future face the same problem and can’t find a working solution (like I was). This may help.
Thanks for posting your solution.
It’s also very helpful to mark the question as answered so people can more easily find it.
P.S. - The TEXT macro is specifically for properly interpreting string literals in the code. It essentially tells UE4 how to interpret string literals as an FString. If you look at the Internal_LocTableFromFile footprint, it wants you to pass it an FString. (FStringTableRegistry::Internal_LocTableFromFile | Unreal Engine Documentation). You don’t need TCHAR_TO_UTF8 at all, just call the function and pass it your FString variable.
The original mistake, ironically, was using the LOCTABLE_FROMFILE_GAME macro in the first place, the macro is only there to help you get FStrings (and FNames) from string literals.
P.P.S. - You can pass an FString to a function expecting an FName by dereferencing the FString pointer.
void WantsFName(FName FooName) {}
FString FooString;
void GivesString() {
WantsFName(*FooString);// this will work
WantsFName(FooString);// this will not
}
Apologies for reviving such an old thread, but I think this is important info for people coming here from google: The localization dashboard WILL NOT find your string table unless you use the macro. If you want to localize your c++ defined string table, you have to use the macro.
…which brings back to the string literals being a massive PIA, which is what I’m currently banging my head against But you can see the scraping logic for yourself in GatherTextFromSourceCommandlet.cpp - that macro functions as a flag for the text gatherer to find the table. No macro, no localization.