Files
o3de/Gems/GraphCanvas/Code/Source/Translation/TranslationDatabase.h
T
Luis Sempé 9e2a3226fd Script Canvas, replace the text replacement system to a JSON file based one (#5228)
It is now possible to right click on nodes on the node palette to navigate to the file that holds the text data for any given node, this way it is easy to update and improve the naming of titles, subtitles, categories, tool tips and slots.
2021-11-11 11:53:51 -08:00

61 lines
1.7 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <Translation/TranslationBus.h>
#include <Translation/TranslationAsset.h>
#include <AzCore/Asset/AssetManagerBus.h>
#include <AzFramework/Asset/GenericAssetHandler.h>
#include <AzFramework/Asset/AssetCatalogBus.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/prettywriter.h>
#include <rapidjson/rapidjson.h>
namespace GraphCanvas
{
// This does not get stored as-is, this is built up during editor load
// time and becomes the one source of truth for translated or "pretty named" things.
class TranslationDatabase
: protected TranslationRequestBus::Handler
, protected AZ::Data::AssetBus::MultiHandler
, protected AZ::Data::AssetCatalogRequestBus::Handler
, protected AzFramework::AssetCatalogEventBus::Handler
{
public:
TranslationDatabase();
~TranslationDatabase();
void Init();
void Restore() override;
void DumpDatabase(const AZStd::string& filename) override;
bool HasKey(const AZStd::string& key) override;
TranslationRequests::Details GetDetails(const AZStd::string& key, const Details& value) override;
bool Get(const AZStd::string& key, AZStd::string& value) override;
bool Add(const TranslationFormat& format) override;
private:
bool IsDuplicate(const AZStd::string& key);
AZStd::unordered_map<AZStd::string, AZStd::string> m_database;
AZStd::recursive_mutex m_mutex;
};
}