-
Notifications
You must be signed in to change notification settings - Fork 18
/
Language.cs
88 lines (80 loc) · 1.97 KB
/
Language.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
/*
* Created by SharpDevelop.
* User: Gheyret Kenji
* Date: 2009/06/15
* Time: 10:38
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace UyghurEditPP
{
/// <summary>
/// Description of Language.
/// </summary>
public class Language
{
dynamic gLangJson = null;
public Language()
{
LoadLanguageData();
LanguaID ="uly";
}
public String LanguaID{
get;
set;
}
void LoadLanguageData(){
try{
String strRes ="UyghurEditPP.langdata.json";
System.Reflection.Assembly asm =System.Reflection.Assembly.GetExecutingAssembly();
Stream stm=asm.GetManifestResourceStream(strRes);
if(stm==null) return;
System.IO.StreamReader rd=new StreamReader(stm,System.Text.Encoding.UTF8);
String jsonstr = rd.ReadToEnd();
gLangJson = DynaJson.Parse(jsonstr);
rd.Close();
stm.Close();
}catch(Exception ee){
System.Diagnostics.Debug.WriteLine(ee.Message);
}
}
StringBuilder gBuf = new StringBuilder();
List<string> gTmp = new List<string>();
public String GetText(String key)
{
String ret=key;
if(gLangJson!=null && (LanguaID.Equals("jpn")||LanguaID.Equals("eng"))){
if(gLangJson.IsDefined(key)){
ret = gLangJson[key][LanguaID];
if(string.IsNullOrEmpty(ret)){
ret = key;
}
}
else{
if(gTmp.Contains(key)==false){
gTmp.Add(key);
string str= String.Format("\"{0}\":{{\"jpn\":\"\",\"eng\":\"\"}},",key);
gBuf.AppendLine(str);
}
}
}
else{
if(LanguaID.Equals("uey")){
ret = Uyghur.ULY2UEY(key);
}
else if(LanguaID.Equals("usy")){
ret = Uyghur.ULY2USY(key);
}
}
return ret;
}
public void Save(string filename){
string jstr = "{" + gBuf.ToString()+ "}";
File.WriteAllText(filename,jstr,Encoding.UTF8);
}
}
}