LocalisedStrings and Resources


#1

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::setCurrentMappings(localisedStr);
LocalisedStrings(filenameLang, false);
"

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

Thanks for your support.

Paulo


#2

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


#3

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 !

Paulo


#4

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

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

 


#5

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.

 

 


#6

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


#7

So i should use it this way ?

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

 


#8

yep


#9

Thank you Jules