Skip to main content

O guia completo da localização no Unreal Engine

Das macros FText às cadeias de fallback: localize seu jogo UE5 com o painel de localização, tabelas de strings, C++, Blueprints e tradução automatizada.

1

FText e o pipeline de localização

FText é o tipo de string do Unreal Engine que reconhece localização. Todas as strings destinadas aos jogadores —etiquetas da interface, diálogos, descrições e notificações— devem utilizar FText para entrarem no pipeline. FString se destina apenas à lógica interna.

LOCTEXT exige dois argumentos: uma chave e uma string de origem. A chave deve ser única no espaço de nomes. O coletor de texto da UE as utiliza para acompanhar traduções entre culturas. NSLOCTEXT permite indicar explicitamente o espaço; LOCTEXT utiliza o definido pela macro LOCTEXT_NAMESPACE envolvente.
FText Basics
// FText is UE's localization-aware string type.
// ALWAYS use FText for user-facing text, never FString.

// LOCTEXT: localize a literal string (most common)
FText Title = LOCTEXT("MainMenuTitle", "Start Game");

// NSLOCTEXT: specify namespace explicitly
FText Msg = NSLOCTEXT("UI", "WelcomeMessage", "Welcome, adventurer!");

// INVTEXT: invariant text (never translated — debug/logging only)
FText Debug = INVTEXT("Debug overlay active");

// FText::Format: safe variable interpolation
FText Greeting = FText::Format(
    LOCTEXT("PlayerGreeting", "Hello, {PlayerName}!"),
    FText::FromString(PlayerName)
);
MainMenuWidget.cpp
// In a UMG Widget (C++)
void UMainMenuWidget::NativeConstruct()
{
    Super::NativeConstruct();

    // Bind localized text to UI elements
    if (TitleLabel)
    {
        TitleLabel->SetText(LOCTEXT("GameTitle", "My Epic Game"));
    }

    if (PlayButton)
    {
        PlayButton->SetText(LOCTEXT("PlayButtonLabel", "Play Now"));
    }
}

// IMPORTANT: Always use LOCTEXT for UMG widget text.
// Setting text via FString bypasses the localization pipeline.
Nunca crie texto para usuários com FString::Printf ou concatenação. Ignoram totalmente o pipeline e o texto não pode ser coletado, traduzido ou apresentado corretamente em RTL. Utilize sempre FText::Format com padrões LOCTEXT.
2

Configurar o painel de localização

O painel de localização é a ferramenta integrada da UE para gerenciar traduções. Coleta as strings LOCTEXT e NSLOCTEXT do código-fonte, as exporta para .po e compila os resultados em binários .locres carregados durante a execução.

Localization Dashboard Workflow
# 1. Open the Localization Dashboard:
#    Window > Localization Dashboard

# 2. Add a localization target (e.g., "Game")

# 3. Add cultures:
#    Click "Add New Culture" > select languages (de, ja, fr, es, ko, zh-Hans...)

# 4. Gather text:
#    Click "Gather Text" — UE scans all LOCTEXT/NSLOCTEXT macros

# 5. Export translations:
#    Click "Export" to generate .po files for each culture

# 6. Import translations:
#    After translating .po files, click "Import"

# 7. Compile translations:
#    Click "Compile" to generate .locres binary files

# 8. Preview:
#    Editor Preferences > Region & Language > Preview Game Language
Execute 'Gather Text' após cada alteração que adicione ou modifique macros LOCTEXT. Sem este passo, as novas strings não aparecem nos .po e os tradutores não as veem. Adicione uma etapa de coleta à automatização da compilação.
3

Utilizar tabelas de strings em texto orientado por dados

As tabelas permitem definir strings localizadas em um ativo centralizado em vez de espalhar macros LOCTEXT. São ideais para interface, diálogos e texto que designers ou escritores precisam de editar sem tocar no código. Podem ser ativos da UE ou importadas de CSV.

StringTableUsage.cpp
// StringTables provide a data-driven approach to localization.
// Define strings in a CSV asset instead of scattering LOCTEXT across code.

// 1. Create a String Table asset:
//    Content Browser > Right-click > Miscellaneous > String Table

// 2. Or define via CSV (importable into UE):
// Key,SourceString
// MainMenu_Title,Start Game
// MainMenu_Continue,Continue
// MainMenu_Settings,Settings
// MainMenu_Quit,Quit to Desktop
// HUD_Health,Health
// HUD_Ammo,Ammo: {0}
// Dialog_Merchant_Greeting,Welcome to my shop!

// 3. Reference in C++:
FText Title = FText::FromStringTable(
    FName(TEXT("/Game/Localization/ST_MainMenu")),
    TEXT("MainMenu_Title")
);

// 4. Reference in Blueprints:
//    Use the "Make Text from String Table" node
//    Set Table ID and Key
As tabelas são coletadas automaticamente pelo painel. Não precisa de macros LOCTEXT: referencie-as pelo ID e pela chave em C++ ou Blueprints.
4

Padrões de localização em C++

Em C++, defina LOCTEXT_NAMESPACE no início de cada .cpp e utilize LOCTEXT em todas as strings para usuários. Utilize FText::Format no conteúdo dinâmico com variáveis. Anule sempre o espaço no fim do arquivo para evitar fugas.

MainMenuWidget.cpp
// Define a namespace at the top of each .cpp file
// All LOCTEXT calls in this file use this namespace
#define LOCTEXT_NAMESPACE "MyGame.MainMenu"

#include "MainMenuWidget.h"

void UMainMenuWidget::NativeConstruct()
{
    Super::NativeConstruct();

    // These use the "MyGame.MainMenu" namespace automatically
    TitleText->SetText(LOCTEXT("Title", "Main Menu"));
    PlayText->SetText(LOCTEXT("PlayButton", "Play"));
    SettingsText->SetText(LOCTEXT("SettingsButton", "Settings"));
    QuitText->SetText(LOCTEXT("QuitButton", "Quit"));
}

// CRITICAL: Always undefine at the end of the file
#undef LOCTEXT_NAMESPACE
FText::Format Examples
// FText::Format — the safe way to build localized strings
// NEVER use FString::Printf or string concatenation for user-facing text.

// Named arguments (recommended)
FText ItemPickup = FText::Format(
    LOCTEXT("ItemPickup", "You picked up {ItemName} x{Count}"),
    FText::FromString(ItemName),
    FText::AsNumber(Count)
);

// FText::AsNumber respects locale formatting:
//   English: 1,234,567
//   German:  1.234.567
//   French:  1 234 567

// FText::AsCurrency for prices:
FText Price = FText::AsCurrency(
    9.99,
    TEXT("USD"),
    &FInternationalization::Get().GetCurrentCulture().Get()
);

// FText::AsDate and FText::AsTime for dates:
FText DateStr = FText::AsDate(FDateTime::Now());
Os argumentos de FText::Format também devem ser FText, não FString em bruto. Utilize FText::FromString() para converter FString, FText::AsNumber() na formatação regional de números e FText::AsCurrency() nos preços. Concatenar FString produz texto que não respeita as regras regionais.
5

Localização em Blueprint

Todas as propriedades Text em Blueprints são FText por padrão, logo estão prontas para localização. Defina Key e Namespace no painel de detalhes para permitir a coleta. Utilize o nó Format Text no conteúdo dinâmico com variáveis.

Blueprint Localization Patterns
// Blueprint Localization Basics:
//
// 1. All Text properties in Blueprints are FText by default
//    (already localization-ready)
//
// 2. Set the Text property in the Details panel
//    Expand the dropdown to set:
//    - Key: unique identifier for translation
//    - Namespace: grouping for organization
//    - Source String: the text to display/translate
//
// 3. For dynamic text, use the "Format Text" node:
//    Format: "Hello, {PlayerName}!"
//    Connect a "Find" pin named "PlayerName" to your variable
//
// 4. For plurals, use "Text Format with Arguments":
//    Pattern: "{Count}|plural(one=item,other=items)"
//
// 5. Culture switching at runtime:
//    Use "Set Current Culture" node
//    Input: culture code string (e.g., "de", "ja", "fr")
Expanda a lista da propriedade text no painel Details de Blueprint para ver Key, Namespace e Source String. Uma Key significativa facilita muito a identificação pelos tradutores no arquivo .po.
6

Tratar plurais e gênero

O Unreal Engine aceita o formato ICU em plurais e texto dependente do gênero. Defina as regras nas strings de origem e a UE seleciona automaticamente a forma correta segundo CLDR da cultura ativa.

ICU Plural & Gender Rules
// UE uses ICU message format for plurals.
// Define plural rules in your .po or String Table:

// English source:
// "{Count}|plural(one=You have # item,other=You have # items)"

// German translation:
// "{Count}|plural(one=Du hast # Gegenstand,other=Du hast # Gegenstaende)"

// Arabic translation (6 forms):
// "{Count}|plural(zero=لا عناصر,one=عنصر واحد,two=عنصران,few=# عناصر,many=# عنصرًا,other=# عنصر)"

// Japanese (1 form):
// "{Count}|plural(other=アイテム#個)"

// In C++:
FText ItemCount = FText::Format(
    LOCTEXT("ItemCount",
        "{Count}|plural(one=You have {Count} item,other=You have {Count} items)"),
    ItemCount
);

// Gender-dependent text:
// "{Gender}|gender(masculine=Il est,feminine=Elle est) prêt{Gender}|gender(masculine=,feminine=e)"
Nunca codifique diretamente count == 1. O francês considera 0 singular, o russo tem formas separadas para 'few' e 'many' e o árabe tem 6 formas. Deixe as regras ICU tratar a lógica: defina as formas e a UE escolhe a correta.
7

Empacotar e testar a localização

Antes do lançamento, confirme se todas as culturas de destino têm .locres compilados e se o texto é apresentado corretamente. Utilize a prévia cultural do editor, substituições na linha de comandos e verificações automáticas para detectar traduções em falta ou danificadas.

Packaging & Testing Workflow
# Compile and test localization before packaging:

# 1. Editor Preferences > Region & Language > Preview Game Language
#    Set to each target language and verify all text renders correctly.

# 2. Command-line culture override for testing:
MyGame.exe -culture=ja

# 3. Packaging settings:
#    Project Settings > Packaging > Localizations to Package
#    Select all cultures you want to include in the build.

# 4. Verify .locres files exist after packaging:
MyGame/Content/Localization/Game/
├── en/
│   └── Game.locres
├── de/
│   └── Game.locres
├── ja/
│   └── Game.locres
├── fr/
│   └── Game.locres
└── ko/
    └── Game.locres

# 5. Runtime culture switching:
#    FInternationalization::Get().SetCurrentCulture(TEXT("ja"));
#    This reloads all FText strings from the new culture's .locres files.
Se uma cultura não constar de Project Settings > Packaging > Localizations to Package, os respectivos .locres são excluídos da compilação. Os jogadores que a selecionarem veem texto de fallback ou strings vazias. Confirme sempre se as configurações correspondem às culturas compatíveis.
8

Adicionar cadeias de fallback regional

A localização predefinida do Unreal Engine só percorre a hierarquia de subetiquetas IETF. Um usuário pt-BR sem tradução recebe inglês em vez de pt-PT. locale-chain-ue adiciona cadeias laterais configuráveis através de FTextLocalizationManager para mostrar a tradução mais próxima.

locale-chain-ue (C++)
// locale-chain-ue: Smart fallback chains for UE5
// Problem: UE falls back to default when a locale is missing.
// pt-BR user gets English instead of pt-PT translations.

// Solution: One function call at startup.
#include "LocaleChain.h"

void UMyGameInstance::Init()
{
    Super::Init();
    ULocaleChain::Configure();  // Load 75 built-in fallback chains
}

// Now resolve strings with per-key fallback:
FString Greeting = ULocaleChain::Resolve(
    TEXT("greeting"), TEXT("MyNamespace")
);
// pt-BR user: tries pt-BR -> pt-PT -> pt -> default

// Custom overrides:
TMap<FString, FString> Overrides;
Overrides.Add(TEXT("pt-BR"), TEXT("pt"));       // Simplify chain
Overrides.Add(TEXT("sv-FI"), TEXT("sv"));        // Add new chain
ULocaleChain::ConfigureWithOverrides(Overrides);

// Full control (C++ only):
TMap<FString, TArray<FString>> Custom;
Custom.Add(TEXT("pt-BR"), {TEXT("pt-PT"), TEXT("pt")});
Custom.Add(TEXT("es-MX"), {TEXT("es-419"), TEXT("es")});
ULocaleChain::ConfigureCustom(Custom, false);
Chame ULocaleChain::Configure() uma vez no início para carregar 75 cadeias integradas em 11 famílias linguísticas. Utilize ConfigureWithOverrides para personalização em Blueprint ou ConfigureCustom em C++ para controle total.

Automatizar a qualidade das traduções

Detecte chaves em falta e marcadores danificados antes da publicação com i18n-validate. Teste a interface com pseudotraduções através de i18n-pseudo antes de chegarem as traduções reais.

Erros frequentes

Utilizar FString no texto para usuários

FString ignora todo o pipeline. O texto criado com FString::Printf ou concatenação não pode ser coletado, traduzido nem apresentado corretamente em RTL. Utilize sempre FText com macros LOCTEXT e FText::Format.

#undef LOCTEXT_NAMESPACE em falta

Esquecer #undef LOCTEXT_NAMESPACE no fim de um .cpp faz o espaço se propagar às unidades seguintes. Isto atribui silenciosamente espaços errados às strings de outros arquivos e mostra traduções no contexto incorreto.

Lógica de plural codificada diretamente

Escrever 'count == 1 ? singular : plural' ignora CLDR. O francês considera 0 singular, o russo tem 4 formas e o árabe 6. Utilize sintaxe ICU nos padrões FText e deixe a UE aplicar as regras da cultura.

Esquecer de compilar após a importação

Importar .po atualiza os dados de texto, mas não gera binários .locres. O jogo continua carregando traduções antigas durante a execução. Execute sempre 'Compile' no painel após importar ou adicione-o à automatização da compilação.

Estrutura de projeto recomendada

Project Structure
MyUnrealProject/
├── Config/
│   └── Localization/
│       └── Game.ini                  # Localization target config
├── Content/
│   └── Localization/
│       ├── Game/
│       │   ├── Game.manifest         # Gather manifest
│       │   ├── en/
│       │   │   ├── Game.po           # Source strings (.po)
│       │   │   └── Game.locres       # Compiled binary
│       │   ├── de/
│       │   │   ├── Game.po
│       │   │   └── Game.locres
│       │   ├── ja/
│       │   │   ├── Game.po
│       │   │   └── Game.locres
│       │   └── fr/
│       │       ├── Game.po
│       │       └── Game.locres
│       └── StringTables/
│           ├── ST_MainMenu.uasset    # String Table asset
│           └── ST_HUD.uasset
├── Plugins/
│   └── LocaleChain/                  # locale-chain-ue plugin
│       ├── LocaleChain.uplugin
│       └── Source/
│           └── LocaleChain/
├── Source/
│   └── MyGame/
│       ├── UI/
│       │   ├── MainMenuWidget.h
│       │   └── MainMenuWidget.cpp    # LOCTEXT macros here
│       └── MyGameInstance.cpp        # ULocaleChain::Configure()
└── MyUnrealProject.uproject

Experimente já o i18n Agent

Solte aqui seu arquivo de tradução

JSON, YAML, PO, XML, CSV, Markdown, Properties

ou clique para selecionar

Idiomas de destino

Sem cadastroEstimativa imediata

Perguntas frequentes