1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added a parameter to the LocalisedStrings constructors to fix a case-sensitivity problem.

This commit is contained in:
jules 2013-05-06 20:19:10 +01:00
parent 4da8eb3ec1
commit 88b50c5d7e
2 changed files with 13 additions and 20 deletions

View file

@ -23,14 +23,14 @@
==============================================================================
*/
LocalisedStrings::LocalisedStrings (const String& fileContents)
LocalisedStrings::LocalisedStrings (const String& fileContents, bool ignoreCase)
{
loadFromText (fileContents);
loadFromText (fileContents, ignoreCase);
}
LocalisedStrings::LocalisedStrings (const File& fileToLoad)
LocalisedStrings::LocalisedStrings (const File& fileToLoad, bool ignoreCase)
{
loadFromText (fileToLoad.loadFileAsString());
loadFromText (fileToLoad.loadFileAsString(), ignoreCase);
}
LocalisedStrings::~LocalisedStrings()
@ -60,7 +60,7 @@ namespace
{
LeakAvoidanceTrick()
{
const ScopedPointer<LocalisedStrings> dummy (new LocalisedStrings (String()));
const ScopedPointer<LocalisedStrings> dummy (new LocalisedStrings (String(), false));
}
};
@ -99,8 +99,10 @@ namespace
}
}
void LocalisedStrings::loadFromText (const String& fileContents)
void LocalisedStrings::loadFromText (const String& fileContents, bool ignoreCase)
{
translations.setIgnoresCase (ignoreCase);
StringArray lines;
lines.addLines (fileContents);
@ -138,11 +140,6 @@ void LocalisedStrings::loadFromText (const String& fileContents)
}
}
void LocalisedStrings::setIgnoresCase (const bool shouldIgnoreCase)
{
translations.setIgnoresCase (shouldIgnoreCase);
}
//==============================================================================
void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations)
{

View file

@ -81,14 +81,16 @@ public:
When you create one of these, you can call setCurrentMappings() to make it
the set of mappings that the system's using.
*/
LocalisedStrings (const String& fileContents);
LocalisedStrings (const String& fileContents,
bool ignoreCaseOfKeys);
/** Creates a set of translations from a file.
When you create one of these, you can call setCurrentMappings() to make it
the set of mappings that the system's using.
*/
LocalisedStrings (const File& fileToLoad);
LocalisedStrings (const File& fileToLoad,
bool ignoreCaseOfKeys);
/** Destructor. */
~LocalisedStrings();
@ -167,19 +169,13 @@ public:
const StringArray& getCountryCodes() const { return countryCodes; }
//==============================================================================
/** Indicates whether to use a case-insensitive search when looking up a string.
This defaults to true.
*/
void setIgnoresCase (bool shouldIgnoreCase);
private:
//==============================================================================
String languageName;
StringArray countryCodes;
StringPairArray translations;
void loadFromText (const String& fileContents);
void loadFromText (const String&, bool ignoreCase);
JUCE_LEAK_DETECTOR (LocalisedStrings)
};