Files
UnrealEngineUWP/Engine/Source/Developer/LocalizationService/Private/LocalizationServiceHelpers.cpp

93 lines
3.1 KiB
C++
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
#include "LocalizationServiceHelpers.h"
#include "ILocalizationServiceProvider.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "Misc/Paths.h"
#include "Misc/ConfigCacheIni.h"
#include "ILocalizationServiceModule.h"
#define LOCTEXT_NAMESPACE "LocalizationServiceHelpers"
namespace LocalizationServiceHelpers
{
const FString& GetSettingsIni()
{
if (ILocalizationServiceModule::Get().GetUseGlobalSettings())
{
return GetGlobalSettingsIni();
}
else
{
static FString LocalizationServiceSettingsIni;
if (LocalizationServiceSettingsIni.Len() == 0)
{
Temp backout while Josh is out so that we don't break workflows and he can re-backout/unrevert this when he's back in. * Contains some selected back outs from other cls that included config context dependent changes, though it's limited to only backing out broken parts as much as possible to minimize surface area. [Backout] - CL20029182 [FYI] josh.adams Original CL Desc ----------------------------------------------------------------- - Adding FConfigContext which is used to repalce LoadExternalIniFile, LoadLocalIniFile, etc, as well as have localized data for all configs read on a thread (like the other platform configs loaded in the editor) - The Load*IniFile functions will create a Context, but eventually those APIs will go away and the Context will be the only way to load ini files - Simplified some of the ini loading code, like removing the HierarchyCache (it wasn't helping editor load times, and added much complexity, and was not thread-safe, and it shouldn't actually be helpful because all the calls to Load*IniFile should eventually be replaced with either GConfig or FCOnfigCacheIni::ForPlatform(), which won't need to re-read in files - Ini reading time actually went down due to the simplification, including Cache removal - Left in old code for now behing a #define (USE_CONTEXT) in case something goes wrong - Added in VERIFY_CONTEXT mode which I used to run original and Context modes and compare (including preflighting builds) (I also added a Compare function that we may want to keep around to use for future debugging) - Added a separate set of config layers for plugins which speeds up plugin parsing, but also will fix the issue with BaseEngine.ini vs DefaultEngine.ini in Engine vs Project plugins (this shows how Contexts can bring useful information down into the guts - however a later change will enable it) - Once this is all seen to be working, I will clean up the non-Context functions, and some globals vs static members, etc #rb paul.chipchase #preflight 62716c1c5e6ce673f452005a #ROBOMERGE-AUTHOR: josh.adams #ROBOMERGE-SOURCE: CL 20029165 via CL 20029180 via CL 20905839 via CL 20905880 #ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v971-20777995) [CL 20908094 by mic rooney in ue5-main branch]
2022-06-30 20:54:32 -04:00
const FString LocalizationServiceSettingsDir = FPaths::GeneratedConfigDir();
FConfigCacheIni::LoadGlobalIniFile(LocalizationServiceSettingsIni, TEXT("LocalizationServiceSettings"), NULL, false, false, true, true, *LocalizationServiceSettingsDir);
}
return LocalizationServiceSettingsIni;
}
}
const FString& GetGlobalSettingsIni()
{
static FString LocalizationServiceGlobalSettingsIni;
if (LocalizationServiceGlobalSettingsIni.Len() == 0)
{
Temp backout while Josh is out so that we don't break workflows and he can re-backout/unrevert this when he's back in. * Contains some selected back outs from other cls that included config context dependent changes, though it's limited to only backing out broken parts as much as possible to minimize surface area. [Backout] - CL20029182 [FYI] josh.adams Original CL Desc ----------------------------------------------------------------- - Adding FConfigContext which is used to repalce LoadExternalIniFile, LoadLocalIniFile, etc, as well as have localized data for all configs read on a thread (like the other platform configs loaded in the editor) - The Load*IniFile functions will create a Context, but eventually those APIs will go away and the Context will be the only way to load ini files - Simplified some of the ini loading code, like removing the HierarchyCache (it wasn't helping editor load times, and added much complexity, and was not thread-safe, and it shouldn't actually be helpful because all the calls to Load*IniFile should eventually be replaced with either GConfig or FCOnfigCacheIni::ForPlatform(), which won't need to re-read in files - Ini reading time actually went down due to the simplification, including Cache removal - Left in old code for now behing a #define (USE_CONTEXT) in case something goes wrong - Added in VERIFY_CONTEXT mode which I used to run original and Context modes and compare (including preflighting builds) (I also added a Compare function that we may want to keep around to use for future debugging) - Added a separate set of config layers for plugins which speeds up plugin parsing, but also will fix the issue with BaseEngine.ini vs DefaultEngine.ini in Engine vs Project plugins (this shows how Contexts can bring useful information down into the guts - however a later change will enable it) - Once this is all seen to be working, I will clean up the non-Context functions, and some globals vs static members, etc #rb paul.chipchase #preflight 62716c1c5e6ce673f452005a #ROBOMERGE-AUTHOR: josh.adams #ROBOMERGE-SOURCE: CL 20029165 via CL 20029180 via CL 20905839 via CL 20905880 #ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v971-20777995) [CL 20908094 by mic rooney in ue5-main branch]
2022-06-30 20:54:32 -04:00
const FString LocalizationServiceSettingsDir = FPaths::EngineSavedDir() + TEXT("Config/");
FConfigCacheIni::LoadGlobalIniFile(LocalizationServiceGlobalSettingsIni, TEXT("LocalizationServiceSettings"), NULL, false, false, true, true, *LocalizationServiceSettingsDir);
}
return LocalizationServiceGlobalSettingsIni;
}
//LOCALIZATIONSERVICE_API extern bool CommitTranslation(const FString& Culture, const FString& Namespace, const FString& Source, const FString& Translation)
//{
// if (!Culture.IsValid() || Culture->GetName().IsEmpty())
// {
// FMessageLog("LocalizationService").Error(LOCTEXT("CultureNotSpecified", "Culture not specified"));
// return false;
// }
// if (!ILocalizationServiceModule::Get().IsEnabled())
// {
// FMessageLog("LocalizationService").Error(LOCTEXT("LocalizationServiceDisabled", "Localization Service is not enabled."));
// return false;
// }
// if (!ILocalizationServiceModule::Get().GetProvider().IsAvailable())
// {
// FMessageLog("SourceControl").Error(LOCTEXT("ILocalizationServiceUnavailable", "Localization Ser is currently not available."));
// return false;
// }
// bool bSuccessfullyCheckedOut = false;
// ILocalizationServiceProvider& Provider = ILocalizationServiceModule::Get().GetProvider();
// //TArray<TSharedRef<ILocalizationServiceState, ESPMode::ThreadSafe>> TranslationStates;
// TSharedPtr<ILocalizationServiceState, ESPMode::ThreadSafe> LocalizationServiceState = Provider.GetState(FLocalizationServiceTranslationIdentifier(Culture, Namespace, Source), ELocalizationServiceCacheUsage::ForceUpdate);
// if (LocalizationServiceState.IsValid())
// {
// // TODO: Finish
// }
//}
}
FScopedLocalizationService::FScopedLocalizationService()
{
ILocalizationServiceModule::Get().GetProvider().Init();
}
FScopedLocalizationService::~FScopedLocalizationService()
{
ILocalizationServiceModule::Get().GetProvider().Close();
}
ILocalizationServiceProvider& FScopedLocalizationService::GetProvider()
{
return ILocalizationServiceModule::Get().GetProvider();
}
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#undef LOCTEXT_NAMESPACE