forked from fdorg/flashdevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextHelper.cs
More file actions
40 lines (36 loc) · 1.4 KB
/
Copy pathTextHelper.cs
File metadata and controls
40 lines (36 loc) · 1.4 KB
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
using System;
using System.Reflection;
using System.Resources;
using PluginCore.Managers;
namespace PluginCore.Localization
{
public class TextHelper
{
private static ResourceManager resourceManager = null;
private static LocaleVersion storedLocale = LocaleVersion.en_US;
/// <summary>
/// Gets the specified localized string
/// </summary>
public static String GetString(String key)
{
String result; String prefix;
if (PluginBase.MainForm == null || PluginBase.MainForm.Settings == null) return key;
LocaleVersion localeSetting = PluginBase.MainForm.Settings.LocaleVersion;
if (resourceManager == null || localeSetting != storedLocale)
{
storedLocale = localeSetting;
String path = "PluginCore.PluginCore.Resources." + storedLocale.ToString();
resourceManager = new ResourceManager(path, Assembly.GetExecutingAssembly());
}
prefix = Assembly.GetCallingAssembly().GetName().Name;
result = resourceManager.GetString(prefix + "." + key);
if (result == null) result = resourceManager.GetString(key);
if (result == null)
{
TraceManager.Add("No localized string found: " + key);
result = String.Empty;
}
return result;
}
}
}