Unreal Engine के स्थानीयकरण की संपूर्ण गाइड
FText मैक्रो से लेकर लोकेल फ़ॉलबैक चेन तक: Localization Dashboard, String Tables, C++, Blueprints और स्वचालित अनुवाद की मदद से अपने UE5 गेम को स्थानीयकृत करें।
FText और स्थानीयकरण पाइपलाइन
FText, Unreal Engine का स्थानीयकरण-सक्षम स्ट्रिंग प्रकार है। स्थानीयकरण पाइपलाइन में शामिल होने के लिए आपके गेम की हर यूज़र को दिखाई देने वाली स्ट्रिंग—UI लेबल, डायलॉग, टूलटिप और नोटिफ़िकेशन—में FText का उपयोग होना चाहिए। FString केवल आंतरिक लॉजिक के लिए है।
// 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)
);// 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.Localization Dashboard सेट अप करें
Localization Dashboard, अनुवादों को प्रबंधित करने के लिए UE में उपलब्ध टूल है। यह आपके स्रोत कोड से सभी LOCTEXT और NSLOCTEXT स्ट्रिंग एकत्र करता है, उन्हें अनुवाद के लिए .po फ़ाइलों के रूप में एक्सपोर्ट करता है और परिणामों को .locres बाइनरी फ़ाइलों में कंपाइल करता है, जिन्हें UE रनटाइम पर लोड करता है।
# 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डेटा-आधारित टेक्स्ट के लिए String Tables का उपयोग करें
String Tables की मदद से आप स्रोत फ़ाइलों में LOCTEXT मैक्रो बिखेरने के बजाय स्थानीयकृत स्ट्रिंग को एक केंद्रीकृत एसेट में परिभाषित कर सकते हैं। ये UI टेक्स्ट, डायलॉग और ऐसी किसी भी स्ट्रिंग के लिए उपयुक्त हैं जिसे डिज़ाइनर या लेखक कोड में बदलाव किए बिना संपादित करना चाहते हैं। String Tables को UE एसेट के रूप में परिभाषित या CSV से इंपोर्ट किया जा सकता है।
// 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 KeyC++ स्थानीयकरण पैटर्न
C++ में हर .cpp फ़ाइल के शीर्ष पर LOCTEXT_NAMESPACE परिभाषित करें और यूज़र को दिखाई देने वाली सभी स्ट्रिंग के लिए LOCTEXT का उपयोग करें। वेरिएबल वाले डायनेमिक कंटेंट के लिए FText::Format का उपयोग करें। नेमस्पेस लीक होने से रोकने के लिए फ़ाइल के अंत में उसे हमेशा अपरिभाषित करें।
// 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 — 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());Blueprint स्थानीयकरण
Blueprints की सभी Text प्रॉपर्टी डिफ़ॉल्ट रूप से FText होती हैं, इसलिए वे पहले से स्थानीयकरण के लिए तैयार हैं। स्ट्रिंग को एकत्र करने योग्य बनाने के लिए प्रॉपर्टी डिटेल पैनल में Key और Namespace सेट करें। वेरिएबल वाले डायनेमिक कंटेंट के लिए Format Text नोड का उपयोग करें।
// 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")बहुवचन और लिंग प्रबंधित करें
Unreal Engine बहुवचन और लिंग पर निर्भर टेक्स्ट के लिए ICU मैसेज फ़ॉर्मैट का समर्थन करता है। अपनी स्रोत स्ट्रिंग में बहुवचन नियम परिभाषित करें और UE सक्रिय कल्चर के CLDR नियमों के आधार पर अपने-आप सही रूप चुन लेगा।
// 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)"स्थानीयकरण को पैकेज और टेस्ट करें
रिलीज़ करने से पहले पुष्टि करें कि सभी लक्षित कल्चर की .locres फ़ाइलें कंपाइल हो चुकी हैं और टेक्स्ट रनटाइम पर सही ढंग से रेंडर होता है। गुम या खराब अनुवाद पकड़ने के लिए Editor के कल्चर प्रीव्यू, कमांड-लाइन कल्चर ओवरराइड और स्वचालित जाँच का उपयोग करें।
# 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.लोकेल फ़ॉलबैक चेन जोड़ें
Unreal Engine का डिफ़ॉल्ट स्थानीयकरण केवल IETF सबटैग पदानुक्रम के अनुसार फ़ॉलबैक करता है। अगर किसी pt-BR यूज़र के लिए कोई अनुवाद उपलब्ध नहीं है, तो उसे पूरी तरह उपयुक्त pt-PT अनुवाद के बजाय अंग्रेज़ी मिलती है। locale-chain-ue, FTextLocalizationManager के माध्यम से कॉन्फ़िगर की जा सकने वाली समानांतर फ़ॉलबैक चेन जोड़ता है, ताकि क्षेत्रीय यूज़र को हमेशा निकटतम उपलब्ध अनुवाद दिखाई दे।
// 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);अनुवाद की गुणवत्ता को स्वचालित करें
आम समस्याएँ
यूज़र को दिखाई देने वाले टेक्स्ट के लिए FString का उपयोग
#undef LOCTEXT_NAMESPACE का न होना
हार्डकोड किया गया बहुवचन लॉजिक
इंपोर्ट के बाद कंपाइल करना भूल जाना
प्रोजेक्ट की सुझाई गई संरचना
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इनका भी अनुवाद करें:
i18n Agent अभी आज़माएँ
अपनी अनुवाद फ़ाइल यहाँ छोड़ें
JSON, YAML, PO, XML, CSV, Markdown, Properties
या ब्राउज़ करने के लिए क्लिक करें
लक्षित भाषाएँ