POFormat
POFormat
#Overview
name: POFormat
The value of this variable can be defined or overridden in .ini config files. 4
.ini config files referencing this setting variable.
It is referenced in 11
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of POFormat is to specify the format of Portable Object (PO) files used in Unreal Engine’s localization system. PO files are a standard format for storing translated text, and this setting allows developers to choose between different PO file formats.
POFormat is primarily used in the localization subsystem of Unreal Engine. It is referenced in the Localization module and the TranslationEditor module, which are responsible for managing and editing translations within the engine.
The value of this variable is typically set in configuration files or through the Unreal Engine editor interface. It is defined as an enumeration (EPortableObjectFormat) with possible values such as “Unreal” or other supported PO formats.
This variable interacts with other localization-related settings, such as:
- CollapseMode: Determines how text is collapsed when exporting to PO files.
- ShouldPersistCommentsOnExport: Controls whether user comments in existing PO files should be preserved during export.
- ShouldAddSourceLocationsAsComments: Determines if source locations should be added as comments in PO file entries.
Developers should be aware that:
- The chosen POFormat affects how localization data is exported and imported.
- Different PO formats may have varying levels of compatibility with third-party translation tools.
- Changing the POFormat may require adjustments to existing localization workflows or tools.
Best practices when using this variable include:
- Consistently use the same POFormat across all localization targets in a project to maintain compatibility.
- Choose a format that is compatible with your localization pipeline and any external translation services you may use.
- Document the chosen POFormat in your project’s localization guidelines to ensure all team members are aware of the format being used.
- Test the localization import/export process thoroughly when changing the POFormat to ensure compatibility with existing translations and tools.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/Localization/EngineOverrides_Export.ini:29, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
EPortableObjectFormat::Unreal
- Is Array:
False
Location: <Workspace>/Projects/Lyra/Config/Localization/EngineOverrides_Import.ini:29, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
EPortableObjectFormat::Unreal
- Is Array:
False
Location: <Workspace>/Projects/Lyra/Config/Localization/Game_Export.ini:29, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
EPortableObjectFormat::Unreal
- Is Array:
False
Location: <Workspace>/Projects/Lyra/Config/Localization/Game_Import.ini:29, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
EPortableObjectFormat::Unreal
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Developer/Localization/Private/LocalizationConfigurationScript.cpp:605
Scope (from outer to inner):
file
namespace LocalizationConfigurationScript
function FLocalizationConfigurationScript GenerateImportTextConfigFile
Source code excerpt:
UEnum* POFormatEnum = FindObjectChecked<UEnum>(nullptr, TEXT("/Script/Localization.EPortableObjectFormat"));
const FName POFormatName = POFormatEnum->GetNameByValue((int64)Target->Settings.ExportSettings.POFormat);
ConfigSection.Add(TEXT("POFormat"), POFormatName.ToString());
}
Script.AddGatherTextStep(0, MoveTemp(ConfigSection));
}
Script.Dirty = true;
#Loc: <Workspace>/Engine/Source/Developer/Localization/Private/LocalizationConfigurationScript.cpp:734
Scope (from outer to inner):
file
namespace LocalizationConfigurationScript
function FLocalizationConfigurationScript GenerateExportTextConfigFile
Source code excerpt:
UEnum* POFormatEnum = FindObjectChecked<UEnum>(nullptr, TEXT("/Script/Localization.EPortableObjectFormat"));
const FName POFormatName = POFormatEnum->GetNameByValue((int64)Target->Settings.ExportSettings.POFormat);
ConfigSection.Add(TEXT("POFormat"), POFormatName.ToString());
ConfigSection.Add(TEXT("ShouldPersistCommentsOnExport"), Target->Settings.ExportSettings.ShouldPersistCommentsOnExport ? TEXT("true") : TEXT("false"));
ConfigSection.Add(TEXT("ShouldAddSourceLocationsAsComments"), Target->Settings.ExportSettings.ShouldAddSourceLocationsAsComments ? TEXT("true") : TEXT("false"));
}
Script.AddGatherTextStep(0, MoveTemp(ConfigSection));
#Loc: <Workspace>/Engine/Source/Developer/Localization/Private/UserGeneratedContentLocalization.cpp:375
Scope (from outer to inner):
file
namespace UserGeneratedContentLocalization
function bool ExportLocalization
Source code excerpt:
ConfigSection.Add(TEXT("bImportLoc"), TEXT("true"));
ConfigSection.Add(TEXT("POFormat"), StaticEnum<EPortableObjectFormat>()->GetNameStringByValue((int64)UGCLocDescriptorForImport.PoFormat));
GatherConfig.AddGatherTextStep(GatherStepIndex++, MoveTemp(ConfigSection));
}
// Export PO
{
#Loc: <Workspace>/Engine/Source/Developer/Localization/Private/UserGeneratedContentLocalization.cpp:387
Scope (from outer to inner):
file
namespace UserGeneratedContentLocalization
function bool ExportLocalization
Source code excerpt:
ConfigSection.Add(TEXT("bExportLoc"), TEXT("true"));
ConfigSection.Add(TEXT("POFormat"), StaticEnum<EPortableObjectFormat>()->GetNameStringByValue((int64)ExportOptions.UGCLocDescriptor.PoFormat));
ConfigSection.Add(TEXT("ShouldPersistCommentsOnExport"), TEXT("true"));
GatherConfig.AddGatherTextStep(GatherStepIndex++, MoveTemp(ConfigSection));
}
#Loc: <Workspace>/Engine/Source/Developer/Localization/Public/LocalizationTargetTypes.h:311
Scope (from outer to inner):
file
function FLocalizationExportingSettings
Source code excerpt:
FLocalizationExportingSettings()
: CollapseMode(ELocalizedTextCollapseMode::IdenticalTextIdAndSource)
, POFormat(EPortableObjectFormat::Unreal)
, ShouldPersistCommentsOnExport(false)
, ShouldAddSourceLocationsAsComments(true)
{
}
/* How should we collapse down text when exporting to PO? */
#Loc: <Workspace>/Engine/Source/Developer/Localization/Public/LocalizationTargetTypes.h:323
Scope: file
Source code excerpt:
/* Which format of PO file should we use? */
UPROPERTY(config, EditAnywhere, Category = "Format", AdvancedDisplay)
EPortableObjectFormat POFormat;
/* Should user comments in existing PO files be persisted after export? Useful if using a third party service that stores editor/translator notes in the PO format's comment fields. */
UPROPERTY(config, EditAnywhere, Category = "Comments")
bool ShouldPersistCommentsOnExport;
/* Should source locations be added to PO file entries as comments? Useful if a third party service doesn't expose PO file reference comments, which typically store the source location. */
#Loc: <Workspace>/Engine/Source/Editor/TranslationEditor/Private/TranslationDataManager.cpp:892
Scope (from outer to inner):
file
function bool FTranslationDataManager::SaveSelectedTranslations
Source code excerpt:
PortableObjectDom.SetLanguage(CultureName);
PortableObjectDom.CreateNewHeader(GetDefault<UGeneralProjectSettings>()->CopyrightNotice);
PortableObjectPipeline::UpdatePOFileHeaderForSettings(PortableObjectDom, LocalizationTarget->Settings.ExportSettings.CollapseMode, LocalizationTarget->Settings.ExportSettings.POFormat);
TArray<UTranslationUnit*>& TranslationsArray = DataManager->GetAllTranslationsArray();
TSharedPtr<TArray<UTranslationUnit*>> EditedItems = Item.Value;
// For each edited item belonging to this manifest/archive pair
for (auto EditedItemIt = EditedItems->CreateIterator(); EditedItemIt; ++EditedItemIt)
#Loc: <Workspace>/Engine/Source/Editor/TranslationEditor/Private/TranslationDataManager.cpp:923
Scope: file
Source code excerpt:
{
TSharedRef<FPortableObjectEntry> PoEntry = MakeShareable(new FPortableObjectEntry());
PortableObjectPipeline::PopulateBasicPOFileEntry(*PoEntry, Translation->Namespace, ContextInfo.Key, nullptr, Translation->Source, Translation->Translation, LocalizationTarget->Settings.ExportSettings.CollapseMode, LocalizationTarget->Settings.ExportSettings.POFormat);
//@TODO: We support additional metadata entries that can be translated. How do those fit in the PO file format? Ex: isMature
PoEntry->AddReference(ContextInfo.Context); // Source location.
PoEntry->AddExtractedComment(PortableObjectPipeline::GetConditionedKeyForExtractedComment(ContextInfo.Key)); // "Notes from Programmer" in the form of the Key.
PoEntry->AddExtractedComment(PortableObjectPipeline::GetConditionedReferenceForExtractedComment(ContextInfo.Context)); // "Notes from Programmer" in the form of the Source Location, since this comes in handy too and OneSky doesn't properly show references, only comments.
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/InternationalizationExportCommandlet.cpp:131
Scope (from outer to inner):
file
function int32 UInternationalizationExportCommandlet::Main
Source code excerpt:
// Read in the PO format to use
EPortableObjectFormat POFormat = EPortableObjectFormat::Unreal;
{
FString POFormatName;
if (GetStringFromConfig(*SectionName, TEXT("POFormat"), POFormatName, ConfigPath))
{
UEnum* POFormatEnum = FindObjectChecked<UEnum>(nullptr, TEXT("/Script/Localization.EPortableObjectFormat"));
const int64 POFormatInt = POFormatEnum->GetValueByName(*POFormatName);
if (POFormatInt != INDEX_NONE)
{
POFormat = (EPortableObjectFormat)POFormatInt;
}
}
}
bool bDoImport = false;
GetBoolFromConfig(*SectionName, TEXT("bImportLoc"), bDoImport, ConfigPath);
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/InternationalizationExportCommandlet.cpp:172
Scope (from outer to inner):
file
function int32 UInternationalizationExportCommandlet::Main
Source code excerpt:
// Import all PO files
if (!PortableObjectPipeline::ImportAll(LocTextHelper, SourcePath, Filename, TextCollapseMode, POFormat, bUseCultureDirectory))
{
UE_LOG(LogInternationalizationExportCommandlet, Error, TEXT("Failed to import localization files."));
return -1;
}
}
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/InternationalizationExportCommandlet.cpp:197
Scope (from outer to inner):
file
function int32 UInternationalizationExportCommandlet::Main
Source code excerpt:
// Export all PO files
if (!PortableObjectPipeline::ExportAll(LocTextHelper, DestinationPath, Filename, TextCollapseMode, POFormat, bShouldPersistComments, bUseCultureDirectory))
{
UE_LOG(LogInternationalizationExportCommandlet, Error, TEXT("Failed to export localization files."));
return -1;
}
}