Loading...
Searching...
No Matches
juce_LocalisedStrings.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API LocalisedStrings
{
public:
//==============================================================================
LocalisedStrings (const String& fileContents, bool ignoreCaseOfKeys);
LocalisedStrings (const File& fileToLoad, bool ignoreCaseOfKeys);
LocalisedStrings (const LocalisedStrings&);
LocalisedStrings& operator= (const LocalisedStrings&);
~LocalisedStrings() = default;
//==============================================================================
static void setCurrentMappings (LocalisedStrings* newTranslations);
static LocalisedStrings* getCurrentMappings();
static String translateWithCurrentMappings (const String& text);
static String translateWithCurrentMappings (const char* text);
//==============================================================================
String translate (const String& text) const;
String translate (const String& text, const String& resultIfNotFound) const;
String getLanguageName() const { return languageName; }
const StringArray& getCountryCodes() const { return countryCodes; }
const StringPairArray& getMappings() const { return translations; }
//==============================================================================
void addStrings (const LocalisedStrings&);
void setFallback (LocalisedStrings* fallbackStrings);
private:
//==============================================================================
String languageName;
StringArray countryCodes;
StringPairArray translations;
std::unique_ptr<LocalisedStrings> fallback;
void loadFromText (const String&, bool ignoreCase);
JUCE_LEAK_DETECTOR (LocalisedStrings)
};
//==============================================================================
#ifndef TRANS
#define TRANS(stringLiteral) juce::translate (stringLiteral)
#endif
#define NEEDS_TRANS(stringLiteral) (stringLiteral)
JUCE_API String translate (const String& stringLiteral);
JUCE_API String translate (const char* stringLiteral);
JUCE_API String translate (CharPointer_UTF8 stringLiteral);
JUCE_API String translate (const String& stringLiteral, const String& resultIfNotFound);
} // namespace juce
juce::File
Definition juce_File.h:45
juce::LocalisedStrings
Definition juce_LocalisedStrings.h:72
juce::LocalisedStrings::getCountryCodes
const StringArray & getCountryCodes() const
Definition juce_LocalisedStrings.h:166
juce::LocalisedStrings::setCurrentMappings
static void setCurrentMappings(LocalisedStrings *newTranslations)
Definition juce_LocalisedStrings.cpp:174
juce::LocalisedStrings::getMappings
const StringPairArray & getMappings() const
Definition juce_LocalisedStrings.h:169
juce::LocalisedStrings::translateWithCurrentMappings
static String translateWithCurrentMappings(const String &text)
Definition juce_LocalisedStrings.cpp:185
juce::LocalisedStrings::~LocalisedStrings
~LocalisedStrings()=default
juce::LocalisedStrings::translate
String translate(const String &text) const
Definition juce_LocalisedStrings.cpp:52
juce::LocalisedStrings::getCurrentMappings
static LocalisedStrings * getCurrentMappings()
Definition juce_LocalisedStrings.cpp:180
juce::LocalisedStrings::LocalisedStrings
LocalisedStrings(const String &fileContents, bool ignoreCaseOfKeys)
Definition juce_LocalisedStrings.cpp:26
juce::LocalisedStrings::getLanguageName
String getLanguageName() const
Definition juce_LocalisedStrings.h:155
juce::StringArray
Definition juce_StringArray.h:35
juce::StringPairArray
Definition juce_StringPairArray.h:35
juce::String
Definition juce_String.h:53