|
|
|
@@ -43,11 +43,17 @@ LocalisedStrings::~LocalisedStrings() |
|
|
|
//==============================================================================
|
|
|
|
String LocalisedStrings::translate (const String& text) const
|
|
|
|
{
|
|
|
|
if (fallback != nullptr && ! translations.containsKey (text))
|
|
|
|
return fallback->translate (text);
|
|
|
|
|
|
|
|
return translations.getValue (text, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
String LocalisedStrings::translate (const String& text, const String& resultIfNotFound) const
|
|
|
|
{
|
|
|
|
if (fallback != nullptr && ! translations.containsKey (text))
|
|
|
|
return fallback->translate (text, resultIfNotFound);
|
|
|
|
|
|
|
|
return translations.getValue (text, resultIfNotFound);
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -73,7 +79,7 @@ namespace |
|
|
|
SpinLock currentMappingsLock;
|
|
|
|
ScopedPointer<LocalisedStrings> currentMappings;
|
|
|
|
|
|
|
|
int findCloseQuote (const String& text, int startPos)
|
|
|
|
static int findCloseQuote (const String& text, int startPos)
|
|
|
|
{
|
|
|
|
juce_wchar lastChar = 0;
|
|
|
|
String::CharPointerType t (text.getCharPointer() + startPos);
|
|
|
|
@@ -92,7 +98,7 @@ namespace |
|
|
|
return startPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
String unescapeString (const String& s)
|
|
|
|
static String unescapeString (const String& s)
|
|
|
|
{
|
|
|
|
return s.replace ("\\\"", "\"")
|
|
|
|
.replace ("\\\'", "\'")
|
|
|
|
@@ -141,6 +147,8 @@ void LocalisedStrings::loadFromText (const String& fileContents, bool ignoreCase |
|
|
|
countryCodes.removeEmptyStrings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
translations.minimiseStorageOverheads();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LocalisedStrings::addStrings (const LocalisedStrings& other)
|
|
|
|
@@ -151,6 +159,11 @@ void LocalisedStrings::addStrings (const LocalisedStrings& other) |
|
|
|
translations.addArray (other.translations);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LocalisedStrings::setFallback (LocalisedStrings* f)
|
|
|
|
{
|
|
|
|
fallback = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations)
|
|
|
|
{
|
|
|
|
|