forked from mc2labs/MissionPlanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
L10N.cs
68 lines (63 loc) · 2.04 KB
/
L10N.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
using MissionPlanner.Properties;
using MissionPlanner.Utilities;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace MissionPlanner
{
public class L10N
{
public static CultureInfo ConfigLang;
static L10N()
{
ConfigLang = GetConfigLang();
Strings.Culture = ConfigLang;
//In .NET 4.5,System.Globalization.CultureInfo.DefaultThreadCurrentCulture & DefaultThreadCurrentUICulture is avaiable
}
public static CultureInfo GetConfigLang()
{
CultureInfo ci = CultureInfoEx.GetCultureInfo(MainV2.getConfig("language"));
if (ci != null)
{
return ci;
}
else
{
return System.Globalization.CultureInfo.CurrentUICulture;
}
}
public static string ReplaceMirrorUrl(ref string url)
{
switch (ConfigLang.Name)
{
case "zh-CN":
case "zh-Hans":
if (url.Contains("firmware.diydrones.com"))
{
url = url.Replace("firmware.diydrones.com", "firmware.diywrj.com");
}
else if (url.Contains("raw.github.com"))
{
url = url.Replace("raw.github.com", "githubraw.diywrj.com");
}
/*
else if (url.Contains("raw.githubusercontent.com"))
{
url = url.Replace("raw.githubusercontent.com", "githubraw.diywrj.com");
}
else if (url.Contains("github.com"))
{
url = url.Replace("github.com", "github.diywrj.com");
}
*/
break;
default:
break;
}
return url;
}
}
}