69
|
1 // This file (AbstractTranslationSet.cs) is a part of the IBBoard project and is copyright 2010 IBBoard
|
|
2 //
|
|
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
|
|
4
|
|
5 using System;
|
|
6 using System.Collections.Generic;
|
|
7
|
|
8 namespace IBBoard.Lang
|
|
9 {
|
|
10 /// <summary>
|
|
11 /// A collection of translations for a given language. The abstract class must be extended by implementations that
|
|
12 /// provide different ways of loading the data.
|
|
13 /// </summary>
|
|
14 public class AbstractTranslationSet
|
|
15 {
|
|
16 private string langCode;
|
|
17 protected Dictionary<string, string> translations;
|
|
18
|
|
19 public AbstractTranslationSet(string languageCode)
|
|
20 {
|
|
21 langCode = languageCode;
|
|
22 translations = new Dictionary<string, string>();
|
|
23 }
|
|
24
|
|
25 /// <summary>
|
|
26 /// Gets the language code that this translation claims to be for
|
|
27 /// </summary>
|
|
28 public string LanguageCode
|
|
29 {
|
|
30 get { return langCode; }
|
|
31 }
|
|
32
|
|
33 /// <summary>
|
|
34 /// Gets a translation from the translation set, or <code>null</code> if the translation doesn't exist.
|
|
35 /// </summary>
|
|
36 /// <param name="key">
|
|
37 /// The key (ID) of the translation to retrieve
|
|
38 /// </param>
|
|
39 public string this[string key]
|
|
40 {
|
|
41 set
|
|
42 {
|
|
43 translations[key] = value;
|
|
44 }
|
|
45 get
|
|
46 {
|
|
47 return DictionaryUtils.GetValue(translations, key);
|
|
48 }
|
|
49 }
|
|
50 }
|
|
51 }
|