Skip to content

Commit

Permalink
Merge pull request #23 from tolgee/feature/ignore-generated-keys
Browse files Browse the repository at this point in the history
Add option to ignore keys generated by Unreal
  • Loading branch information
pasotee authored Apr 3, 2024
2 parents 4183efa + 325442c commit 8c7c58e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Source/Tolgee/Public/TolgeeSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class TOLGEE_API UTolgeeSettings : public UDeveloperSettings
*/
UPROPERTY(Config, EditAnywhere, Category = "Tolgee Localization")
TArray<FString> Languages;
/**
* @brief With this enabled only strings from string tables will be uploaded & translated. Generated Keys (produced by Unreal for strings outside of string tables) will be ignored.
*/
UPROPERTY(Config, EditAnywhere, Category = "Tolgee Localization")
bool bIgnoreGeneratedKeys = true;
/**
* @brief Should we automatically fetch translation data at runtime?
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ TArray<FLocalizationKey> UTolgeeEditorIntegrationSubsystem::GetKeysFromTargets(T
{
TArray<FLocalizationKey> KeysFound;

const UTolgeeSettings* TolgeeSettings = GetDefault<UTolgeeSettings>();

for (const ULocalizationTarget* LocalizationTarget : LocalizationTargets)
{
GWarn->BeginSlowTask(LOCTEXT("LoadingManifestData", "Loading Entries from Current Translation Manifest..."), true);
Expand Down Expand Up @@ -230,6 +232,13 @@ TArray<FLocalizationKey> UTolgeeEditorIntegrationSubsystem::GetKeysFromTargets(T
GWarn->StatusUpdate(CurrentManifestEntry, TotalManifestEntries, ProgressText);

const TSharedRef<FManifestEntry> ManifestEntry = ManifestItr.Value();

if(TolgeeSettings->bIgnoreGeneratedKeys && ManifestEntry->Namespace.IsEmpty())
{
// Only generated keys have no namespace. Keys from string tables are required to have a one.
continue;
}

for (auto ContextIter(ManifestEntry->Contexts.CreateConstIterator()); ContextIter; ++ContextIter)
{
FLocalizationKey& NewKey = KeysFound.Emplace_GetRef();
Expand Down

0 comments on commit 8c7c58e

Please sign in to comment.