Display more video information in MediaInfo Tab.
[marukotoolbox.git] / mp4box / ResourceCulture.cs
blob253fae32443e8ab71db996263df36ae9beb6f51c
1 // ------------------------------------------------------------------
2 // Copyright (C) 2011-2014 Maruko Toolbox Project
3 //
4 // Authors: komaruchan <sandy_0308@hotmail.com>
5 //
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
9 //
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;
26 namespace mp4box
28 class ResourceCulture
30 /// <summary>
31 /// Set current culture by name
32 /// </summary>
33 /// <param name="name">name</param>
34 public static void SetCurrentCulture(string name)
36 if (string.IsNullOrEmpty(name))
38 name = "en-US";
41 Thread.CurrentThread.CurrentCulture = new CultureInfo(name);
44 /// <summary>
45 /// Get string by id
46 /// </summary>
47 /// <param name="id">id</param>
48 /// <returns>current language string</returns>
49 public static string GetString(string id)
51 string strCurLanguage = "";
53 try
55 ResourceManager rm = new ResourceManager("GlobalizationTest.Resource", Assembly.GetExecutingAssembly());
56 CultureInfo ci = Thread.CurrentThread.CurrentCulture;
57 strCurLanguage = rm.GetString(id, ci);
59 catch
61 strCurLanguage = "No id:" + id + ", please add.";
64 return strCurLanguage;