Language and localization stuff moved here from MBS.Framework.UserInterface
This commit is contained in:
parent
3fbcb738dd
commit
f8a63cfdeb
@ -419,6 +419,18 @@ namespace MBS.Framework
|
|||||||
System.Diagnostics.Debug.WriteLine(sb);
|
System.Diagnostics.Debug.WriteLine(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Language mvarDefaultLanguage = null;
|
||||||
|
/// <summary>
|
||||||
|
/// The default <see cref="Language"/> used to display translatable text in this application.
|
||||||
|
/// </summary>
|
||||||
|
public Language DefaultLanguage { get { return mvarDefaultLanguage; } set { mvarDefaultLanguage = value; } }
|
||||||
|
|
||||||
|
private Language.LanguageCollection mvarLanguages = new Language.LanguageCollection();
|
||||||
|
/// <summary>
|
||||||
|
/// The languages defined for this application. Translations can be added through XML files in the ~/Languages folder.
|
||||||
|
/// </summary>
|
||||||
|
public Language.LanguageCollection Languages { get { return mvarLanguages; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this <see cref="Application" /> is
|
/// Gets a value indicating whether this <see cref="Application" /> is
|
||||||
/// currently in the process of shutting down.
|
/// currently in the process of shutting down.
|
||||||
|
|||||||
54
MBS.Framework/Language.cs
Normal file
54
MBS.Framework/Language.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MBS.Framework
|
||||||
|
{
|
||||||
|
public class Language
|
||||||
|
{
|
||||||
|
public class LanguageCollection
|
||||||
|
: System.Collections.ObjectModel.Collection<Language>
|
||||||
|
{
|
||||||
|
public Language this[string ID]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
foreach (Language language in this)
|
||||||
|
{
|
||||||
|
if (language.ID == ID) return language;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string mvarID = String.Empty;
|
||||||
|
public string ID { get { return mvarID; } set { mvarID = value; } }
|
||||||
|
|
||||||
|
private string mvarTitle = String.Empty;
|
||||||
|
public string Title { get { return mvarTitle; } set { mvarTitle = value; } }
|
||||||
|
|
||||||
|
private Dictionary<string, string> mvarCommandTitles = new Dictionary<string, string>();
|
||||||
|
private Dictionary<string, string> mvarStringTableEntries = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
public string GetCommandTitle(string id, string defaultValue = null)
|
||||||
|
{
|
||||||
|
if (mvarCommandTitles.ContainsKey(id)) return mvarCommandTitles[id];
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
public void SetCommandTitle(string id, string value)
|
||||||
|
{
|
||||||
|
mvarCommandTitles[id] = value;
|
||||||
|
}
|
||||||
|
public string GetStringTableEntry(string id, string defaultValue = null)
|
||||||
|
{
|
||||||
|
if (mvarStringTableEntries.ContainsKey(id)) return mvarStringTableEntries[id];
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
public void SetStringTableEntry(string id, string value)
|
||||||
|
{
|
||||||
|
mvarStringTableEntries[id] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -134,6 +134,7 @@
|
|||||||
<Compile Include="ObjectExtensions.cs" />
|
<Compile Include="ObjectExtensions.cs" />
|
||||||
<Compile Include="ConsoleExtensions.cs" />
|
<Compile Include="ConsoleExtensions.cs" />
|
||||||
<Compile Include="MessageSeverity.cs" />
|
<Compile Include="MessageSeverity.cs" />
|
||||||
|
<Compile Include="Language.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Logic\" />
|
<Folder Include="Logic\" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user