LocalisedStrings and Resources


Hi there,

is there a way to load the translation file from resources and not from one external file ?

To load from regular file, external, i'm doing this way:

String filenameLang;
String filePath;
filenameLang = "pt_PT.lng";
filePath = File::getCurrentWorkingDirectory().getChildFile(filenameLang).getFullPathName();
File languageFile(filePath);
localisedStr = new LocalisedStrings(languageFile, false);
LocalisedStrings(filenameLang, false);

How to do it if i already included the language file in my resources ?

Thanks for your support.



Well yes.. didn't you notice that it has a constructor that takes a string instead of a file?


Hi Jules,


Can you give me a quick example on how to do it ?

Imagining that i have already a binary that is called "ptPT_lng" that is the translation file.


It was great !



It's pretty trivial to do, unless I'm misunderstanding you?..

E.g. new LocalisedStrings (String (BinaryData::myTranslationFile_txt), false);



I already tried that way, but when starting my application, it give and exception and related with juce:string:

"jassert (t == nullptr || CharPointer_ASCII::isValidString (t, std::numeric_limits<int>::max()));"

and my file is well and in correct format and loaded as resource. Since i can load it externally without any problem.




Well yes - if your file was encoded as utf8 or utf16 then you'd probably want to call String::createStringFromData to create it.


So i should use it this way ?

LocalisedStrings(String::createStringFromData(BinaryData::ptPT_lng, BinaryData::ptPT_lngSize), false);





Thank you Jules