rj-action-library/Runtime/Localization/LocaleText.cs

43 lines
786 B
C#
Raw Normal View History

2025-01-26 09:15:28 +00:00
using Godot;
using System.Collections;
using System.Collections.Generic;
using Godot.Collections;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class LocaleText:LocalizedString
{
[Export(PropertyHint.MultilineText)]
public string en;
[ExportGroup("Translations")]
[Export]
public LocaleTextEntry[] entries;
[ExportGroup("Context")]
[Export(PropertyHint.MultilineText)]
public string context;
public override string GetLocalizedString( LocaleCode localeCode )
{
if ( localeCode == LocaleCode.EN )
{
return en;
}
var entry = Arrays.Find( entries, e => e.code == localeCode );
if ( entry != null )
{
return entry.content;
}
return en;
}
}
}