Localizations
- adding localizations in english and german for default controls - updating default controls
This commit is contained in:
parent
e5dc3fd2bc
commit
d24f8e7ac5
@ -18,7 +18,7 @@ namespace TelegramBotBase.Controls
|
|||||||
public class ButtonGrid : Base.ControlBase
|
public class ButtonGrid : Base.ControlBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public String Title { get; set; } = "Toggle";
|
public String Title { get; set; } = Localizations.Default.Language["ButtonGrid_Title"];
|
||||||
|
|
||||||
public String ConfirmationText { get; set; } = "";
|
public String ConfirmationText { get; set; } = "";
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ namespace TelegramBotBase.Controls
|
|||||||
|
|
||||||
private int? MessageId { get; set; }
|
private int? MessageId { get; set; }
|
||||||
|
|
||||||
public String Title { get; set; } = "Pick Date";
|
public String Title { get; set; } = Localizations.Default.Language["CalendarPicker_Title"];
|
||||||
|
|
||||||
public eMonthPickerMode PickerMode { get; set; }
|
public eMonthPickerMode PickerMode { get; set; }
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ namespace TelegramBotBase.Controls
|
|||||||
|
|
||||||
switch (result.RawData)
|
switch (result.RawData)
|
||||||
{
|
{
|
||||||
case "next":
|
case "$next$":
|
||||||
|
|
||||||
switch (this.PickerMode)
|
switch (this.PickerMode)
|
||||||
{
|
{
|
||||||
@ -74,7 +74,7 @@ namespace TelegramBotBase.Controls
|
|||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "prev":
|
case "$prev$":
|
||||||
|
|
||||||
switch (this.PickerMode)
|
switch (this.PickerMode)
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ namespace TelegramBotBase.Controls
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "monthtitle":
|
case "$monthtitle$":
|
||||||
|
|
||||||
if (this.EnableMonthView)
|
if (this.EnableMonthView)
|
||||||
{
|
{
|
||||||
@ -102,7 +102,7 @@ namespace TelegramBotBase.Controls
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "yeartitle":
|
case "$yeartitle$":
|
||||||
|
|
||||||
if (this.EnableYearView)
|
if (this.EnableYearView)
|
||||||
{
|
{
|
||||||
@ -110,7 +110,7 @@ namespace TelegramBotBase.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "yearstitle":
|
case "$yearstitle$":
|
||||||
|
|
||||||
if (this.EnableMonthView)
|
if (this.EnableMonthView)
|
||||||
{
|
{
|
||||||
@ -179,7 +179,7 @@ namespace TelegramBotBase.Controls
|
|||||||
string[] dayNamesNormal = this.Culture.DateTimeFormat.ShortestDayNames;
|
string[] dayNamesNormal = this.Culture.DateTimeFormat.ShortestDayNames;
|
||||||
string[] dayNamesShifted = Shift(dayNamesNormal, (int)this.FirstDayOfWeek);
|
string[] dayNamesShifted = Shift(dayNamesNormal, (int)this.FirstDayOfWeek);
|
||||||
|
|
||||||
bf.AddButtonRow(new ButtonBase("<<", "prev"), new ButtonBase(this.Culture.DateTimeFormat.MonthNames[month.Month - 1] + " " + month.Year.ToString(), "monthtitle"), new ButtonBase(">>", "next"));
|
bf.AddButtonRow(new ButtonBase(Localizations.Default.Language["CalendarPicker_PreviousPage"], "$prev$"), new ButtonBase(this.Culture.DateTimeFormat.MonthNames[month.Month - 1] + " " + month.Year.ToString(), "$monthtitle$"), new ButtonBase(Localizations.Default.Language["CalendarPicker_NextPage"], "$next$"));
|
||||||
|
|
||||||
bf.AddButtonRow(dayNamesShifted.Select(a => new ButtonBase(a, a)).ToList());
|
bf.AddButtonRow(dayNamesShifted.Select(a => new ButtonBase(a, a)).ToList());
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ namespace TelegramBotBase.Controls
|
|||||||
|
|
||||||
case eMonthPickerMode.month:
|
case eMonthPickerMode.month:
|
||||||
|
|
||||||
bf.AddButtonRow(new ButtonBase("<<", "prev"), new ButtonBase(this.VisibleMonth.Year.ToString("0000"), "yeartitle"), new ButtonBase(">>", "next"));
|
bf.AddButtonRow(new ButtonBase(Localizations.Default.Language["CalendarPicker_PreviousPage"], "$prev$"), new ButtonBase(this.VisibleMonth.Year.ToString("0000"), "$yeartitle$"), new ButtonBase(Localizations.Default.Language["CalendarPicker_NextPage"], "$next$"));
|
||||||
|
|
||||||
var months = this.Culture.DateTimeFormat.MonthNames;
|
var months = this.Culture.DateTimeFormat.MonthNames;
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ namespace TelegramBotBase.Controls
|
|||||||
|
|
||||||
case eMonthPickerMode.year:
|
case eMonthPickerMode.year:
|
||||||
|
|
||||||
bf.AddButtonRow(new ButtonBase("<<", "prev"), new ButtonBase("Year", "yearstitle"), new ButtonBase(">>", "next"));
|
bf.AddButtonRow(new ButtonBase(Localizations.Default.Language["CalendarPicker_PreviousPage"], "$prev$"), new ButtonBase("Year", "$yearstitle$"), new ButtonBase(Localizations.Default.Language["CalendarPicker_NextPage"], "$next$"));
|
||||||
|
|
||||||
var starti = Math.Floor(this.VisibleMonth.Year / 10f) * 10;
|
var starti = Math.Floor(this.VisibleMonth.Year / 10f) * 10;
|
||||||
|
|
||||||
|
|||||||
@ -12,15 +12,15 @@ namespace TelegramBotBase.Controls
|
|||||||
public class ToggleButton : ControlBase
|
public class ToggleButton : ControlBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public String UncheckedIcon { get; set; } = "⚪";
|
public String UncheckedIcon { get; set; } = Localizations.Default.Language["ToggleButton_OffIcon"];
|
||||||
|
|
||||||
public String CheckedIcon { get; set; } = "⚫";
|
public String CheckedIcon { get; set; } = Localizations.Default.Language["ToggleButton_OnIcon"];
|
||||||
|
|
||||||
public String CheckedString { get; set; } = "On";
|
public String CheckedString { get; set; } = Localizations.Default.Language["ToggleButton_On"];
|
||||||
|
|
||||||
public String UncheckedString { get; set; } = "Off";
|
public String UncheckedString { get; set; } = Localizations.Default.Language["ToggleButton_Off"];
|
||||||
|
|
||||||
public String Title { get; set; } = "Toggle";
|
public String Title { get; set; } = Localizations.Default.Language["ToggleButton_Title"];
|
||||||
|
|
||||||
public int? MessageId { get; set; }
|
public int? MessageId { get; set; }
|
||||||
|
|
||||||
|
|||||||
@ -20,12 +20,12 @@ namespace TelegramBotBase.Controls
|
|||||||
|
|
||||||
private int? MessageId { get; set; }
|
private int? MessageId { get; set; }
|
||||||
|
|
||||||
public String MoveUpIcon { get; set; } = "🔼 up";
|
public String MoveUpIcon { get; set; } = Localizations.Default.Language["TreeView_LevelUp"];
|
||||||
|
|
||||||
public TreeView()
|
public TreeView()
|
||||||
{
|
{
|
||||||
this.Nodes = new List<TreeViewNode>();
|
this.Nodes = new List<TreeViewNode>();
|
||||||
this.Title = "Select node";
|
this.Title = Localizations.Default.Language["TreeView_Title"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -52,8 +52,10 @@ namespace TelegramBotBase.Controls
|
|||||||
|
|
||||||
var n = (this.VisibleNode != null ? this.VisibleNode.FindNodeByValue(val) : this.Nodes.FirstOrDefault(a => a.Value == val));
|
var n = (this.VisibleNode != null ? this.VisibleNode.FindNodeByValue(val) : this.Nodes.FirstOrDefault(a => a.Value == val));
|
||||||
|
|
||||||
if (n != null)
|
if (n == null)
|
||||||
{
|
return;
|
||||||
|
|
||||||
|
|
||||||
if (n.ChildNodes.Count > 0)
|
if (n.ChildNodes.Count > 0)
|
||||||
{
|
{
|
||||||
this.VisibleNode = n;
|
this.VisibleNode = n;
|
||||||
@ -64,7 +66,7 @@ namespace TelegramBotBase.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.Handled = true;
|
result.Handled = true;
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ namespace TelegramBotBase.Form
|
|||||||
|
|
||||||
public bool ShowBackButton { get; set; } = false;
|
public bool ShowBackButton { get; set; } = false;
|
||||||
|
|
||||||
public String BackLabel { get; set; } = "Zurück";
|
public String BackLabel { get; set; } = Localizations.Default.Language["PromptDialog_Back"];
|
||||||
|
|
||||||
public PromptDialog()
|
public PromptDialog()
|
||||||
{
|
{
|
||||||
|
|||||||
14
TelegramBotBase/Localizations/Default.cs
Normal file
14
TelegramBotBase/Localizations/Default.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace TelegramBotBase.Localizations
|
||||||
|
{
|
||||||
|
public static class Default
|
||||||
|
{
|
||||||
|
|
||||||
|
public static Localization Language = new English();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
25
TelegramBotBase/Localizations/English.cs
Normal file
25
TelegramBotBase/Localizations/English.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace TelegramBotBase.Localizations
|
||||||
|
{
|
||||||
|
public class English : Localization
|
||||||
|
{
|
||||||
|
public English() : base()
|
||||||
|
{
|
||||||
|
Values["Language"] = "English";
|
||||||
|
Values["ButtonGrid_Title"] = "Menu";
|
||||||
|
Values["ButtonGrid_NoItems"] = "There are no items.";
|
||||||
|
Values["ButtonGrid_CurrentPage"] = "Page {0} of {1}";
|
||||||
|
Values["CalendarPicker_Title"] = "Pick date";
|
||||||
|
Values["TreeView_Title"] = "Select node";
|
||||||
|
Values["TreeView_LevelUp"] = "🔼 level up";
|
||||||
|
Values["ToggleButton_On"] = "On";
|
||||||
|
Values["ToggleButton_Off"] = "Off";
|
||||||
|
Values["ToggleButton_Title"] = "Toggle";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
16
TelegramBotBase/Localizations/German.cs
Normal file
16
TelegramBotBase/Localizations/German.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace TelegramBotBase.Localizations
|
||||||
|
{
|
||||||
|
public class German : Localization
|
||||||
|
{
|
||||||
|
public German() : base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
39
TelegramBotBase/Localizations/Localization.cs
Normal file
39
TelegramBotBase/Localizations/Localization.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace TelegramBotBase.Localizations
|
||||||
|
{
|
||||||
|
public class Localization
|
||||||
|
{
|
||||||
|
public Dictionary<String, String> Values = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
public String this[String key]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Values[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Localization()
|
||||||
|
{
|
||||||
|
Values["Language"] = "Deutsch (German)";
|
||||||
|
Values["ButtonGrid_Title"] = "Menü";
|
||||||
|
Values["CalendarPicker_Title"] = "Datum auswählen";
|
||||||
|
Values["CalendarPicker_PreviousPage"] = "◀️";
|
||||||
|
Values["CalendarPicker_NextPage"] = "▶️";
|
||||||
|
Values["TreeView_Title"] = "Knoten auswählen";
|
||||||
|
Values["TreeView_LevelUp"] = "🔼 Stufe hoch";
|
||||||
|
Values["ToggleButton_On"] = "An";
|
||||||
|
Values["ToggleButton_Off"] = "Aus";
|
||||||
|
Values["ToggleButton_OnIcon"] = "⚫";
|
||||||
|
Values["ToggleButton_OffIcon"] = "⚪";
|
||||||
|
Values["ToggleButton_Title"] = "Schalter";
|
||||||
|
Values["PromptDialog_Back"] = "Zurück";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user