Skip to content

Commit

Permalink
language key int
Browse files Browse the repository at this point in the history
  • Loading branch information
absences committed Jan 25, 2025
1 parent a28bb32 commit 1df8e58
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Luban.Core/Defs/DefAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ protected TType CreateNotContainerType(string module, string rawType, bool conta
return TString.Create(nullable, tags);
case "text":
tags.Add("text", "1");
return TString.Create(nullable, tags);
return TInt.Create(nullable, tags);
case "time":
case "datetime":
return TDateTime.Create(nullable, tags);
Expand Down
5 changes: 4 additions & 1 deletion src/Luban.L10N/DataTarget/TextKeyListCollectorVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public void Accept(DShort data, TType type, TextKeyCollection x)

public void Accept(DInt data, TType type, TextKeyCollection x)
{

if (data != null && type.HasTag("text"))
{
x.AddKey(data.Value.ToString());
}
}

public void Accept(DLong data, TType type, TextKeyCollection x)
Expand Down
6 changes: 3 additions & 3 deletions src/Luban.L10N/TextValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class TextValidator : DataValidatorBase

public override void Compile(DefField field, TType type)
{
if (type is not TString)
if (type is not TInt)
{
throw new Exception($"field:{field} text validator supports string type only");
throw new Exception($"field:{field} text validator supports int type only");
}
}

Expand All @@ -27,7 +27,7 @@ public override void Validate(DataValidatorContext ctx, TType type, DType data)
{
return;
}
string key = ((DString)data).Value;
string key = ((DInt)data).Value.ToString();
if (string.IsNullOrEmpty(key))
{
return;
Expand Down

0 comments on commit 1df8e58

Please sign in to comment.