1
// ------------------------------------------------------------------
2 // Copyright (C) 2011-2014 Maruko Toolbox Project
4 // Authors: komaruchan <sandy_0308@hotmail.com>
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
10 // http://www.apache.org/licenses/LICENSE-2.0
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
15 // express or implied.
16 // See the License for the specific language governing permissions
17 // and limitations under the License.
18 // -------------------------------------------------------------------
21 using System
.Reflection
;
22 using System
.Resources
;
23 using System
.Threading
;
24 using System
.Globalization
;
31 /// Set current culture by name
33 /// <param name="name">name</param>
34 public static void SetCurrentCulture(string name
)
36 if (string.IsNullOrEmpty(name
))
41 Thread
.CurrentThread
.CurrentCulture
= new CultureInfo(name
);
47 /// <param name="id">id</param>
48 /// <returns>current language string</returns>
49 public static string GetString(string id
)
51 string strCurLanguage
= "";
55 ResourceManager rm
= new ResourceManager("GlobalizationTest.Resource", Assembly
.GetExecutingAssembly());
56 CultureInfo ci
= Thread
.CurrentThread
.CurrentCulture
;
57 strCurLanguage
= rm
.GetString(id
, ci
);
61 strCurLanguage
= "No id:" + id
+ ", please add.";
64 return strCurLanguage
;