Browse Source

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

tags/2021-05-28
jules 12 years ago
parent
commit
88b50c5d7e
2 changed files with 13 additions and 20 deletions
  1. +8
    -11
      modules/juce_core/text/juce_LocalisedStrings.cpp
  2. +5
    -9
      modules/juce_core/text/juce_LocalisedStrings.h

+ 8
- 11
modules/juce_core/text/juce_LocalisedStrings.cpp 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)
{


+ 5
- 9
modules/juce_core/text/juce_LocalisedStrings.h 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)
};


Loading…
Cancel
Save