Skip to content

Commit 12e6ef4

Browse files
committed
Added LocalizationManagerWrapper to support Gum localization.
1 parent 802f176 commit 12e6ef4

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

FRBDK/Glue/GumPlugin/GumPlugin/CodeGeneration/GueDerivingClassCodeGenerator.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,18 @@ private ICodeBlock GenerateClassHeader(ICodeBlock codeBlock, ElementSave element
194194

195195
foreach(var behaviorReference in elementSave.Behaviors)
196196
{
197-
var behavior = ObjectFinder.Self.GetBehavior(behaviorReference);
198-
199-
if(behavior != null)
197+
if(ObjectFinder.Self.GumProjectSave != null)
200198
{
201-
// This could be a bad reference, so tolerate it
202-
var fullName = CodeGeneratorManager.Self.BehaviorCodeGenerator
203-
.GetFullyQualifiedBehaviorName(behavior);
199+
var behavior = ObjectFinder.Self.GetBehavior(behaviorReference);
200+
201+
if(behavior != null)
202+
{
203+
// This could be a bad reference, so tolerate it
204+
var fullName = CodeGeneratorManager.Self.BehaviorCodeGenerator
205+
.GetFullyQualifiedBehaviorName(behavior);
204206

205-
inheritance += $", {fullName}";
207+
inheritance += $", {fullName}";
208+
}
206209
}
207210
}
208211

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using FlatRedBall.Localization;
5+
using MonoGameGum.Localization;
6+
7+
namespace GumCoreShared.FlatRedBall.Embedded;
8+
9+
public class LocalizationManagerWrapper : ILocalizationService
10+
{
11+
public string Translate(string stringId)
12+
{
13+
return LocalizationManager.Translate(stringId);
14+
}
15+
16+
17+
}

FRBDK/Glue/GumPlugin/GumPlugin/GumCoreShared.FlatRedBall.projitems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<Compile Include="$(MSBuildThisFileDirectory)Embedded\GumToFrbShapeRelationship.cs" />
1818
<Compile Include="$(MSBuildThisFileDirectory)Embedded\IFrameworkElement.cs" />
1919
<Compile Include="$(MSBuildThisFileDirectory)Embedded\IGumScreenOwner.cs" />
20+
<Compile Include="$(MSBuildThisFileDirectory)Embedded\LocalizationManagerWrapper.cs" />
2021
<Compile Include="$(MSBuildThisFileDirectory)Embedded\PositionedObjectGueWrapper.cs" />
2122
<Compile Include="$(MSBuildThisFileDirectory)Embedded\SystemManagers.FlatRedBall.cs" />
2223
</ItemGroup>

FRBDK/Glue/GumPlugin/GumPlugin/GumPlugin.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<Compile Remove="Embedded\GumCollidableExtensions.cs" />
5656
<Compile Remove="Embedded\GumIdb.cs" />
5757
<Compile Remove="Embedded\GumToFrbShapeRelationship.cs" />
58+
<Compile Remove="Embedded\LocalizationManagerWrapper.cs" />
5859
<Compile Remove="Embedded\PositionedObjectGueWrapper.cs" />
5960
<Compile Remove="Embedded\SystemManagers.FlatRedBall.cs" />
6061
<Compile Remove="Properties\AssemblyInfo.cs" />

0 commit comments

Comments
 (0)