Skip to content

Commit 95da5b0

Browse files
authored
Fix: I18n issues with missing dialog translation. And Add Chinese Translaton Support (#21)
1 parent fe2ecc1 commit 95da5b0

File tree

5 files changed

+218
-18
lines changed

5 files changed

+218
-18
lines changed

AnimalSitter/AnimalSitter.cs

Lines changed: 101 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Object = StardewValley.Object;
1313
using AnimalSitter.Integrations.GenericModConfigMenu;
1414
using Microsoft.Xna.Framework.Input;
15+
using System.Reflection;
1516

1617
namespace AnimalSitter
1718
{
@@ -65,10 +66,12 @@ public class AnimalSitter : Mod
6566

6667
private ModConfig Config;
6768

68-
private DialogueManager DialogueManager;
69+
// private DialogueManager DialogueManager;
6970

7071
private ChestManager ChestManager;
7172

73+
private readonly Random RandomDialogue = new Random();
74+
7275

7376
/*********
7477
** Public methods
@@ -78,7 +81,7 @@ public class AnimalSitter : Mod
7881
public override void Entry(IModHelper helper)
7982
{
8083
this.Config = this.Helper.ReadConfig<ModConfig>();
81-
this.DialogueManager = new DialogueManager(this.Config, helper.ModContent, this.Monitor);
84+
// this.DialogueManager = new DialogueManager(this.Config, helper.ModContent, this.Monitor);
8285
this.ChestManager = new ChestManager(this.Monitor);
8386
I18n.Init(helper.Translation);
8487

@@ -202,7 +205,7 @@ private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
202205
this.ChestManager.SetDefault(this.ChestCoords);
203206

204207
// Read in dialogue
205-
this.DialogueManager.ReadInMessages();
208+
// this.DialogueManager.ReadInMessages();
206209

207210
this.Monitor.Log(I18n.Log_ChestCoords(x: this.ChestCoords.X, y: this.ChestCoords.Y), LogLevel.Trace);
208211
}
@@ -551,28 +554,34 @@ private void ShowMessage(int numActions, int totalCost, bool doesPlayerHaveEnoug
551554
{
552555
if (Game1.player.isMarriedOrRoommates())
553556
{
554-
message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(1, "Xdialog"), stats, this.Config);
557+
string spouse = Game1.player.isMarriedOrRoommates() ? Game1.player.getSpouse().getName() : this.Checker;
558+
// message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(1, "Xdialog"), stats, this.Config);
559+
message += I18n.Dialog_Xdialog1(spouse: spouse);
555560
}
556561
else
557562
{
558-
message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(2, "Xdialog"), stats, this.Config);
563+
// message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(2, "Xdialog"), stats, this.Config);
564+
message += I18n.Dialog_Xdialog2(num_actions: stats.NumActions);
559565
}
560566

561567
if (totalCost > 0 && this.CostPerAnimal > 0)
562568
{
563-
message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(3, "Xdialog"), stats, this.Config);
569+
// message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(3, "Xdialog"), stats, this.Config);
570+
message += I18n.Dialog_Xdialog3(total_cost: stats.TotalCost);
564571
}
565572

566573
HUDMessage msg = new HUDMessage(message);
567574
Game1.addHUDMessage(msg);
568575
}
569576
else if (gatheringOnly)
570577
{
571-
message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(4, "Xdialog"), stats, this.Config);
578+
// message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(4, "Xdialog"), stats, this.Config);
579+
message += I18n.Dialog_Xdialog4(checker: this.Checker);
572580

573581
if (totalCost > 0 && this.CostPerAnimal > 0)
574582
{
575-
message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(3, "Xdialog"), stats, this.Config);
583+
// message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(3, "Xdialog"), stats, this.Config);
584+
message += I18n.Dialog_Xdialog3(total_cost: stats.TotalCost);
576585
}
577586

578587
HUDMessage msg = new HUDMessage(message);
@@ -590,18 +599,22 @@ private void ShowMessage(int numActions, int totalCost, bool doesPlayerHaveEnoug
590599
portrait = "$8";
591600
}
592601

593-
message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetRandomMessage("greeting"), stats, this.Config);
594-
message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(5, "Xdialog"), stats, this.Config);
602+
// message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetRandomMessage("greeting"), stats, this.Config);
603+
// message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(5, "Xdialog"), stats, this.Config);
604+
message += I18n.Dialog_Greeting1(name: Game1.player.Name);
605+
message += I18n.Dialog_Xdialog5();
595606

596607
if (this.CostPerAnimal > 0)
597608
{
598609
if (doesPlayerHaveEnoughCash)
599610
{
600-
message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(6, "Xdialog"), stats, this.Config);
611+
// message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(6, "Xdialog"), stats, this.Config);
612+
message += I18n.Dialog_Xdialog6(total_cost: stats.TotalCost);
601613
}
602614
else
603615
{
604-
message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetRandomMessage("unfinishedmoney"), stats, this.Config);
616+
// message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetRandomMessage("unfinishedmoney"), stats, this.Config);
617+
message += this.GetRandomMessage(messageStoreName: "unfinishedmoney", low: 1, high: 8);
605618
}
606619
}
607620
else
@@ -610,7 +623,8 @@ private void ShowMessage(int numActions, int totalCost, bool doesPlayerHaveEnoug
610623
//message += portrait + "#$e#";
611624
}
612625

613-
message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetRandomMessage("smalltalk"), stats, this.Config);
626+
// message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetRandomMessage("smalltalk"), stats, this.Config);
627+
message += this.GetRandomMessage(messageStoreName: "smalltalk", low: 1, high: 14);
614628
message += portrait + "#$e#";
615629

616630
character.CurrentDialogue.Push(new Dialogue(character, message));
@@ -619,7 +633,8 @@ private void ShowMessage(int numActions, int totalCost, bool doesPlayerHaveEnoug
619633
else
620634
{
621635
//message += checker + " has performed " + numActions + " for your animals.";
622-
message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(7, "Xdialog"), stats, this.Config);
636+
// message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(7, "Xdialog"), stats, this.Config);
637+
message += I18n.Dialog_Xdialog7(checker: this.Checker, num_actions: stats.NumActions);
623638
HUDMessage msg = new HUDMessage(message);
624639
Game1.addHUDMessage(msg);
625640
}
@@ -639,5 +654,77 @@ private List<FarmAnimal> GetAnimals()
639654
return animals;
640655
}
641656

657+
private string GetRandomMessage(string messageStoreName, int low=1, int high=4)
658+
{
659+
var rand = RandomDialogue.Next(low, high + 1);
660+
661+
if (messageStoreName == "greeting")
662+
{
663+
return rand switch
664+
{
665+
1 => I18n.Dialog_Greeting1(name: Game1.player.Name),
666+
2 => I18n.Dialog_Greeting2(name: Game1.player.Name),
667+
3 => I18n.Dialog_Greeting3(name: Game1.player.Name),
668+
4 => I18n.Dialog_Greeting4(name: Game1.player.Name),
669+
5 => I18n.Dialog_Greeting5(name: Game1.player.Name),
670+
6 => I18n.Dialog_Greeting6(name: Game1.player.Name),
671+
7 => I18n.Dialog_Greeting7(name: Game1.player.Name),
672+
_ => I18n.Dialog_Greeting1(name: Game1.player.Name),
673+
};
674+
}
675+
else if (messageStoreName == "unfinishedmoney")
676+
{
677+
return rand switch
678+
{
679+
1 => I18n.Dialog_Unfinishedmoney1(),
680+
2 => I18n.Dialog_Unfinishedmoney2(),
681+
3 => I18n.Dialog_Unfinishedmoney3(),
682+
4 => I18n.Dialog_Unfinishedmoney4(),
683+
5 => I18n.Dialog_Unfinishedmoney5(),
684+
6 => I18n.Dialog_Unfinishedmoney6(),
685+
7 => I18n.Dialog_Unfinishedmoney7(),
686+
8 => I18n.Dialog_Unfinishedmoney8(),
687+
_ => I18n.Dialog_Unfinishedmoney1(),
688+
};
689+
}
690+
else if (messageStoreName == "unfinishedinventory")
691+
{
692+
return rand switch
693+
{
694+
1 => I18n.Dialog_Unfinishedinventory1(),
695+
2 => I18n.Dialog_Unfinishedinventory2(),
696+
3 => I18n.Dialog_Unfinishedinventory3(),
697+
4 => I18n.Dialog_Unfinishedinventory4(),
698+
_ => I18n.Dialog_Unfinishedinventory1(),
699+
};
700+
}
701+
else if (messageStoreName == "smalltalk")
702+
{
703+
return rand switch
704+
{
705+
1 => I18n.Dialog_Smalltalk1(),
706+
2 => I18n.Dialog_Smalltalk2(),
707+
3 => I18n.Dialog_Smalltalk3(),
708+
4 => I18n.Dialog_Smalltalk4(),
709+
5 => I18n.Dialog_Smalltalk5(),
710+
6 => I18n.Dialog_Smalltalk6(),
711+
7 => I18n.Dialog_Smalltalk7(),
712+
8 => I18n.Dialog_Smalltalk8(),
713+
9 => I18n.Dialog_Smalltalk9(),
714+
10 => I18n.Dialog_Smalltalk10(),
715+
11 => I18n.Dialog_Smalltalk11(),
716+
12 => I18n.Dialog_Smalltalk12(),
717+
13 => I18n.Dialog_Smalltalk13(),
718+
14 => I18n.Dialog_Smalltalk14(),
719+
_ => I18n.Dialog_Smalltalk1(),
720+
};
721+
}
722+
else
723+
{
724+
return "...$h#$e#";
725+
}
726+
727+
}
728+
642729
}
643730
}

AnimalSitter/AnimalSitter.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<AssemblyName>AnimalSitter</AssemblyName>
55
<RootNamespace>AnimalSitter</RootNamespace>
6-
<Version>2.2.0</Version>
6+
<Version>2.2.2</Version>
77
<TargetFramework>net6.0</TargetFramework>
88
<Platforms>AnyCPU</Platforms>
99
<PlatformTarget>AnyCPU</PlatformTarget>

AnimalSitter/i18n/zh.json

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"config.KeyBind": "快捷键",
3+
"config.KeyBind.description": "默认'O'键,按下后助手开始工作。",
4+
5+
"config.GrowUpEnabled": "立即成长开关",
6+
"config.GrowUpEnabled.description": "开启后助手会使用神秘力量使你的动物立即长大,并产出产品。默认为关闭。",
7+
8+
"config.MaxHappinessEnabled": "最大快乐值开关",
9+
"config.MaxHappinessEnabled.description": "开启后,无论何时何地,助手会一直照料动物到最大快乐值后才停止工作。默认为关闭。",
10+
11+
"config.MaxFullnessEnabled": "喂养开关",
12+
"config.MaxFullnessEnabled.description": "开启后助手会喂养动物,动物吃饱后会多产。默认为关闭。",
13+
14+
"config.HarvestEnabled": "收获开关",
15+
"config.HarvestEnabled.description": "助手会收集动物产品。如果想自己动手,则设置为关闭。",
16+
17+
"config.PettingEnabled": "抚摸开关",
18+
"config.PettingEnabled.description": "助手会抚摸动物。默认开启。如果想自己动手,则设置为关闭。",
19+
20+
"config.MaxFriendshipEnabled": "好感度开关",
21+
"config.MaxFriendshipEnabled.description": "助手照料动物后,动物好感度是否增长。默认为否。",
22+
23+
"config.CostPerAction": "雇佣金",
24+
"config.CostPerAction.description": "给助手照料每只动物的雇佣金,默认为25金币。",
25+
26+
"config.WhoChecks": "雇员",
27+
"config.WhoChecks.description": "决定谁受雇来照料你的动物,默认为配偶即'spouse'。你可以设置为你的宠物,但不会有太多反馈;也可以设置为其他角色,这样会启动相关对话;还可以设置成别的名字,这个名字会在消息中显示。",
28+
29+
30+
"config.EnableMessages": "信息显示开关",
31+
"config.EnableMessages.description": "是否在游戏中开启动物照料的信息提醒。默认为是。",
32+
33+
"config.TakeTrufflesFromPigs": "修复松露开关",
34+
"config.TakeTrufflesFromPigs.description": "助手会捡拾松露。解决松露变杂草的BUG。",
35+
36+
"config.BypassInventory": "产品入箱开关",
37+
"config.BypassInventory.description": "产品被收集后,是否不进入背包,而是存放在你指定的箱子中,默认为否。",
38+
39+
"config.ChestCoords": "指定箱子位置",
40+
"config.ChestCoords.description": "背包不够,产品溢出时,存放溢出物的箱子位置坐标。默认为(73,14)。",
41+
42+
"config.ChestDefs": "ChestDefs",
43+
"config.ChestDefs.description": "This is a bar-separated list of chest locations that you have defined for specific items. It defaults to blank, but here is an example: '430,70,14|340,7,4,FarmHouse' You can see there are 2 options.",
44+
45+
"dialog.comment_1": "Indexes in this file that are prefixed with an X rely on specific ordering for the in game dialog to make sense. Other ones are randomly selected, so order doesn't matter. Indexes also need to be in the format group_id, with a single underscore.",
46+
"dialog.Xdialog_1": " {{spouse}} 已经照料完动物了。",
47+
"dialog.Xdialog_2": "你的助手完成了 {{num_actions}} 任务。",
48+
"dialog.Xdialog_3": "花费了 {{total_cost}}金币。",
49+
"dialog.Xdialog_4": " {{checker}} 已经收集完了动物产品。",
50+
"dialog.Xdialog_5": "我今天照料完动物了。",
51+
"dialog.Xdialog_6": "我从卡里刷走了 {{total_cost}} 金币。",
52+
"dialog.Xdialog_7": " {{checker}} 完成了给动物 {{num_actions}} 的工作。",
53+
"dialog.greeting_1": "你好啊, {{name}} 。",
54+
"dialog.greeting_2": "早上好, {{name}} 。",
55+
"dialog.greeting_3": "嘿 {{name}} !",
56+
"dialog.greeting_4": "完成了 {{name}} 。",
57+
"dialog.greeting_5": "嘿嘿 {{name}} ,抓到你了。",
58+
"dialog.greeting_6": " {{name}} ,还好嘛?",
59+
"dialog.greeting_7": "农夫 {{name}} !",
60+
"dialog.unfinishedmoney_1": " 因为……嗯……我们聊过的一些金钱上的问题,我没能干完所有活。",
61+
"dialog.unfinishedmoney_2": " 为了你的预算不至于超额,我不得不略过一些工作。",
62+
"dialog.unfinishedmoney_3": " 我没干完所有活。如果你想再找我过来,给我打电话。",
63+
"dialog.unfinishedmoney_4": " 动物数量太多了,你已经负担不起饲养成本了。或许你可以去乔家看看有没有工作机会。",
64+
"dialog.unfinishedmoney_5": " 你没给钱,所以今天我不干了。",
65+
"dialog.unfinishedmoney_6": " 我知道情况,手头不方便了是么。如果你拿出足够的照料其它动物的酬劳,可以再找我。",
66+
"dialog.unfinishedmoney_7": " 除非有人给你邮寄一些现金,并且它们就躺在邮箱里等你。否则你可能得自己照料一些动物了。",
67+
"dialog.unfinishedmoney_8": " 我愿意降一些佣金,但我不想像你一样破产……只是开玩笑。",
68+
"dialog.unfinishedinventory_1": " 看起来你没有足够的地方来存放这些产品。",
69+
"dialog.unfinishedinventory_2": " 你可能得腾出更多的空间了,或者买一个更大的箱子。",
70+
"dialog.unfinishedinventory_3": " 当你有足够空间放剩下的东西时,叫我一声。",
71+
"dialog.unfinishedinventory_4": " 你的包和箱子都没有足够的空间放东西了,你腾出了地方后叫我一声。",
72+
"dialog.smalltalk_1": " 跟你干活特别愉快!",
73+
"dialog.smalltalk_2": " 你提供的这个工作让我挣到了更多钱,起到了很大的作用。",
74+
"dialog.smalltalk_3": " 如果你的农场里还有什么别的工作,记得找我,我会很乐意过来的。",
75+
"dialog.smalltalk_4": " 所以之前生活是怎样对待你的?",
76+
"dialog.smalltalk_5": " 你能决定搬来星露谷,我真的特别高兴。",
77+
"dialog.smalltalk_6": " 现在是一年当中动物产品质量最好的时候。",
78+
"dialog.smalltalk_7": " 你的庄稼长的怎么样啦?",
79+
"dialog.smalltalk_8": " 你最近和你的父母联系了么?",
80+
"dialog.smalltalk_9": " 自从雇我以来,空出的这些时间你都做了什么?",
81+
"dialog.smalltalk_10": " 我特别想问,你对周围流传的那些谣言怎么看?",
82+
"dialog.smalltalk_11": " 对了,我真的挺喜欢你对这个农场的改造的。",
83+
"dialog.smalltalk_12": " 你需要发票收据么?",
84+
"dialog.smalltalk_13": " 我并不是贪婪,但兜里揣着一大堆现金的感觉真的好,不是么?",
85+
"dialog.smalltalk_14": " 我明天一定要休假,你确定明天不自己去看看你的瓶瓶罐罐么?",
86+
"dialog.Shane_1": " 我确定在这比在乔家工作时要好,那个班上的太糟了。",
87+
"dialog.Shane_2": " 我今天走回家,介意我拿一个冰镇的么?",
88+
"dialog.Haley_1": " 这个工作一开始很有趣,但我不确定我能习惯这个味道。",
89+
"dialog.Haley_2": " 如果你觉得无礼,那么我提前说声抱歉。请雇别人来做这个,我感觉我快要死了。$a",
90+
"dialog.Alex_1": " 你有没有考虑过做一些肉类的买卖?我不得不克制自己不去咬你的动物一口!",
91+
"dialog.Leah_1": " 你介意我给你的动物画幅画么?",
92+
"dialog.Marnie_1": " 你照料动物很拿手,难怪它们的产品品质这么好!",
93+
94+
"log.chestCoords": "箱子坐标: {{x}}, {{y}}",
95+
"log.error_parsing_key_bingding": "快捷键绑定错误; 默认为{{default_value}}",
96+
"log.doing_free": "我可以无偿做这个,但我不会付给你钱来照料你的恶臭的动物!",
97+
"log.set_cost_to_0": "将雇佣金设置为0。",
98+
"log.exception_onkeyreleased": "快捷键设为: {{ex}}",
99+
"log.petting_animal": "抚摸了 {{animal_name}} ",
100+
"log.aging_animal": "使 {{animal_name}} 生长到成熟",
101+
"log.feeding_animal": "喂养了 {{animal_name}} ",
102+
"log.max_happiness_animal": " {{animal_name}} 快乐值满了",
103+
"log.max_friendship_animal": " {{animal_name}} 亲密度满了",
104+
"log.has_produce": " {{animal_name}} 生产了 {{animal_currentProduce}} ",
105+
"log.total_cost": "助手完成了 {{actions}} 工作。总计花费: {{total_cost}} 金币",
106+
"log.nothing_to_do": "现在没有能做的。",
107+
"log.inventory_full": "空间满了,无法拾取动物产品。",
108+
"log.found_coop_object": "Found coop object: {{obj_name}} / {{obj_category}}/{{obj_isAnimalProduct}}",
109+
"log.meow": "喵……",
110+
"log.woof": "汪……",
111+
"log.imaginary_pet_take_care": "你幻想的宠物已经照料完了你的动物。"
112+
}

AnimalSitter/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Name": "Animal Sitter LTS",
33
"Author": "oliver",
4-
"Version": "2.2.1",
4+
"Version": "2.2.2",
55
"Description": "Long Term Support Mod Version for Animal Sitter Mod. Let someone else pet all those pesky animals!",
66
"UniqueID": "oliver.AnimalSitterLTS",
77
"EntryDll": "AnimalSitter.dll",

0 commit comments

Comments
 (0)