Unable to make Internationalisation work

Hi,

 

I am trying to get a small JUCE application to display text using the translate() functions.

The application has an embedded text file containing the translations.

In the application initialisation I have:

showLanguages();
ScopedPointer<LocalisedStrings> ls = new LocalisedStrings(String::createStringFromData(BinaryData::french_txt, BinaryData::french_txtSize), true);
logger->logMessage("' from ' is " + translate(" from "));
LocalisedStrings::setCurrentMappings(ls);
        
showLanguages();
        
logger->logMessage("' from ' is now " + translate(" from "));
logger->logMessage(LocalisedStrings::translateWithCurrentMappings(" from "));

ls.release();

and


    void showLanguages()
    {
        logger->logMessage("showLanguages called");
        ScopedPointer<LocalisedStrings> localisedStrings(LocalisedStrings::getCurrentMappings());
        if (!localisedStrings)
            logger->logMessage("No languages set");
        else
        {
            logger->logMessage("Language name : " + localisedStrings->getLanguageName());
            StringArray sa(localisedStrings->getCountryCodes());
            for (int i = 0; i < sa.size(); ++i)
            {
                logger->logMessage("Country code : " + sa[i]);
            }
            //??setlocale()
        }
        localisedStrings.release();
    }

The first few lines of the language file are:


language: French
countries: fr be mc ch lu
" from " = " à partir de"
" trying to connect to database" = " essayer de se connecter à la base de données"
"(no choices)" = "(pas de choix)"

The log file is showing the following output:


showLanguages called
No languages set
' from ' is  from 
showLanguages called
Language name : French
Country code : fr
Country code : be
Country code : mc
Country code : ch
Country code : lu
'( from ' is now  from 
 from 

I can see that the languages file has been loaded from the log file, but I think I've missed something really obvious with getting the language to display en francais.

The app has been developed on a English language version of Windows 8.1, and I have tried executing the code in a Windows 7 French machine and still only get the English output.

I think I've missed something really obvious, but can't see what at the moment. I can push the code into Github if necessary.

Any assistance gratefully received!

On my (English) Windows machine, copypasting your code snippets, compiling and running results in the following correct output:

showLanguages called
No languages set
' from ' is  from
showLanguages called
Language name : French
Country code : fr
Country code : be
Country code : mc
Country code : ch
Country code : lu
' from ' is now  à partir de
 à partir de

which means that the parts of the code that you posted here seem to work correctly. I cannot see anything obvious, the problem seems to be elsewhere.

Just checked on a French Windows version. This results in the same log, internationalisation is working...

Hope this is of some help.

Thanks Timur,

You did help point me into a different place.

When I recoded the app using ScopedPointer<LocalisedStrings> instead of just LocalisedStrings (and no *) the code worked as desired.

Regards,

Neil