-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLanguageManager.cs
276 lines (262 loc) · 12.5 KB
/
LanguageManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;
using System.Windows.Forms;
namespace EasyFTPServer
{
public class LanguageManager
{
public Form form;
public List<Control> controls = new List<Control>();
public string lang = "en";
public void LoadLanguage(string language)
{
if (Languages.ContainsKey(language))
{
lang = language;
Language l = Languages[language];
if (l.Data.ContainsKey(form.Name))
{
form.Text = l.Data[form.Name];
}
foreach (Control c in controls)
{
UpdateControlText(c, l.Data);
}
}
}
public string Get(string key)
{
if (Languages.ContainsKey(lang))
{
return Languages[lang].Data[key];
}
return null;
}
private void UpdateControlText(Control control, Dictionary<string, string> data)
{
if (data.ContainsKey(control.Name))
{
control.Text = data[control.Name];
}
if (control.ContextMenuStrip != null)
{
UpdateContextMenuItems(control.ContextMenuStrip, data);
}
if(control is ContextMenuStrip cms)
{
UpdateContextMenuItems(cms, data);
}
foreach (Control c in control.Controls)
{
UpdateControlText(c, data);
}
}
private void UpdateContextMenuItems(ContextMenuStrip cms, Dictionary<string, string> data)
{
foreach (ToolStripItem i in cms.Items)
{
if (data.ContainsKey(i.Name))
{
i.Text = data[i.Name];
}
}
}
public static Dictionary<string, Language> Languages = new Dictionary<string, Language>()
{
{"zh",new Language()
{
Name="zh",
Data=new Dictionary<string, string>()
{
{"MainForm","简单FTP服务器" },
{"gb_config","服务器配置" },
{"l_rootdir","主文件夹:" },
{"l_username","用户名:" },
{"l_password","密码:" },
{"l_port","端口:" },
{"bt_selectdir","选择文件夹" },
{"bt_start","开启" },
{"bt_stop","关闭" },
{"notifyIcon1","简单FTP服务器" },
{"tsmi_start","开启服务器" },
{"tsmi_stop","关闭服务器" },
{"tsmi_exit","退出程序" },
{"InvaildPort","端口必须是1到65535之间的数字!" },
{"EmptyWarningTitle","空密码警告" },
{"EmptyWarning","您正在使用空用户名和密码,这意味着网络上的所有计算机都可以访问您的文件。您确定要继续吗?" },
}
}},
{"en",new Language()
{
Name="en",
Data=new Dictionary<string, string>()
{
{"MainForm", "EasyFTPServer"},
{"gb_config", "Configuration"},
{"l_rootdir", "RootFolder:"},
{"l_username", "Username:"},
{"l_password", "Password:"},
{"l_port", "Port:"},
{"bt_selectdir", "SelectFolder"},
{"bt_start", "Start"},
{"bt_stop", "Stop"},
{"notifyIcon1", "EasyFTPServer"},
{"tsmi_start", "Start Server"},
{"tsmi_stop", "Stop Server"},
{"tsmi_exit", "Exit Program"},
{"InvaildPort","port must be a number between 1 and 65535!" },
{"EmptyWarningTitle","Empty Password Warning" },
{"EmptyWarning","You are using a empty username and password, which means all computer on the network can access your files. Are you sure to continue?" },
}
}},
{"es",new Language()
{
Name="es",
Data=new Dictionary<string, string>()
{
{"MainForm", "EasyFTPServer"},
{"gb_config", "Configuración"},
{"l_rootdir", "CarpetaRaíz:"},
{"l_username", "NombreUsuario:"},
{"l_password", "Contraseña:"},
{"l_port", "Puerto:"},
{"bt_selectdir", "SeleccionarCarpeta"},
{"bt_start", "Iniciar"},
{"bt_stop", "Detener"},
{"notifyIcon1", "EasyFTPServer"},
{"tsmi_start", "Iniciar Servidor"},
{"tsmi_stop", "Detener Servidor"},
{"tsmi_exit", "Salir del Programa"},
{"InvaildPort","¡El puerto debe ser un número entre 1 y 65535!" },
{"EmptyWarningTitle","Advertencia de contraseña vacía" },
{"EmptyWarning","Estás utilizando un nombre de usuario y contraseña vacíos, lo que significa que todos los equipos de la red pueden acceder a tus archivos. ¿Estás seguro/a de que quieres continuar?" },
}
}},
{"fr",new Language()
{
Name="fr",
Data=new Dictionary<string, string>()
{
{"MainForm", "EasyFTPServer"},
{"gb_config", "Configuration"},
{"l_rootdir", "DossierRacine:"},
{"l_username", "NomUtilisateur:"},
{"l_password", "MotDePasse:"},
{"l_port", "Port:"},
{"bt_selectdir", "SélectionnerDossier"},
{"bt_start", "Démarrer"},
{"bt_stop", "Arrêter"},
{"notifyIcon1", "EasyFTPServer"},
{"tsmi_start", "Démarrer le serveur"},
{"tsmi_stop", "Arrêter le serveur"},
{"tsmi_exit", "Quitter le programme"},
{"InvaildPort","Le port doit être un nombre compris entre 1 et 65535 !" },
{"EmptyWarningTitle","Avertissement de mot de passe vide" },
{"EmptyWarning","Vous utilisez un nom d'utilisateur et un mot de passe vides, ce qui signifie que tous les ordinateurs du réseau peuvent accéder à vos fichiers. Êtes-vous sûr(e) de vouloir continuer?" },
}
}},
{"de",new Language()
{
Name="de",
Data=new Dictionary<string, string>()
{
{"MainForm", "EasyFTPServer"},
{"gb_config", "Konfiguration"},
{"l_rootdir", "Stammverzeichnis:"},
{"l_username", "Benutzername:"},
{"l_password", "Passwort:"},
{"l_port", "Port:"},
{"bt_selectdir", "OrdnerAuswählen"},
{"bt_start", "Starten"},
{"bt_stop", "Stoppen"},
{"notifyIcon1", "EasyFTPServer"},
{"tsmi_start", "ServerStarten"},
{"tsmi_stop", "ServerStoppen"},
{"tsmi_exit", "ProgrammBeenden"},
{"InvaildPort","Der Port muss eine Zahl zwischen 1 und 65535 sein!" },
{"EmptyWarningTitle","Warnung vor leerem Passwort" },
{"EmptyWarning","Sie verwenden einen leeren Benutzernamen und ein leeres Passwort, was bedeutet, dass alle Computer im Netzwerk auf Ihre Dateien zugreifen können. Sind Sie sicher, dass Sie fortfahren möchten?" },
}
}},
{"pt",new Language()
{
Name="pt",
Data=new Dictionary<string, string>()
{
{"MainForm", "EasyFTPServer"},
{"gb_config", "Configuração"},
{"l_rootdir", "PastaRaiz:"},
{"l_username", "NomeUsuário:"},
{"l_password", "Senha:"},
{"l_port", "Porta:"},
{"bt_selectdir", "SelecionarPasta"},
{"bt_start", "Iniciar"},
{"bt_stop", "Parar"},
{"notifyIcon1", "EasyFTPServer"},
{"tsmi_start", "Iniciar Servidor"},
{"tsmi_stop", "Parar Servidor"},
{"tsmi_exit", "Sair do Programa"},
{"InvaildPort","A porta deve ser um número entre 1 e 65535!" },
{"EmptyWarningTitle","Aviso de senha vazia" },
{"EmptyWarning","Você está usando um nome de usuário e senha vazios, o que significa que todos os computadores na rede podem acessar seus arquivos. Tem certeza de que deseja continuar?" },
}
}},
{"ja",new Language()
{
Name="ja",
Data=new Dictionary<string, string>()
{
{"MainForm", "EasyFTPServer"},
{"gb_config", "Configuration"},
{"l_rootdir", "RootFolder:"},
{"l_username", "ユーザー名:"},
{"l_password", "パスワード:"},
{"l_port", "ポート:"},
{"bt_selectdir", "フォルダーの選択"},
{"bt_start", "開始"},
{"bt_stop", "停止"},
{"notifyIcon1", "EasyFTPServer"},
{"tsmi_start", "サーバーの開始"},
{"tsmi_stop", "サーバーの停止"},
{"tsmi_exit", "プログラムの終了"},
{"InvaildPort","ポートは1から65535の間の数字である必要があります!" },
{"EmptyWarningTitle","空のパスワード警告" },
{"EmptyWarning","空のユーザー名とパスワードを使用しています。これにより、ネットワーク上のすべてのコンピュータがあなたのファイルにアクセスできます。続行してもよろしいですか?" },
}
}},
{"ru",new Language()
{
Name="ru",
Data=new Dictionary<string, string>()
{
{"MainForm", "EasyFTPServer"},
{"gb_config", "Конфигурация"},
{"l_rootdir", "КорневаяПапка:"},
{"l_username", "ИмяПользователя:"},
{"l_password", "Пароль:"},
{"l_port", "Порт:"},
{"bt_selectdir", "ВыбратьПапку"},
{"bt_start", "Запуск"},
{"bt_stop", "Остановка"},
{"notifyIcon1", "EasyFTPServer"},
{"tsmi_start", "ЗапуститьСервер"},
{"tsmi_stop", "ОстановитьСервер"},
{"tsmi_exit", "Выход"},
{"InvaildPort","Порт должен быть числом от 1 до 65535!" },
{"EmptyWarningTitle","Предупреждение о пустом пароле" },
{"EmptyWarning","Вы используете пустое имя пользователя и пароль, что означает, что все компьютеры в сети могут получить доступ к вашим файлам. Вы уверены, что хотите продолжить?" },
}
}},
};
}
public class Language
{
public string Name { get; set; }
public Dictionary<string, string> Data { get; set; }
}
}