bonuska1/App/I18n.cs
Slavasil f2653e66d4 add support for translations; basic terminal functions and splash screen
- create I18n class for translations
- create TextDisplay class to draw on console, and to initialize and reset console configuration
- create stub for future command-line option handling
2025-03-23 19:46:25 +03:00

46 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace Game {
public class I18n {
public static readonly string LANGUAGE = "ru-RU";
static readonly Dictionary<string, string[]> LANGUAGES = new Dictionary<string, string[]>() {
{"en-US", new string[] {
"No answers added for question",
"Expected `=>`",
"Expected `True` or `False`",
"Expected `||` between answers",
"The output is not a terminal",
"Syntax error in the question database: {0} ({1}:{2}:{3})",
"Syntax error in the question database: {0} (line {1} column {2})",
"Cannot get console mode",
"Cannot set console mode",
}},
{"ru-RU", new string[] {
"Не указано ни одного варианта ответа на вопрос",
"Ожидалось `=>`",
"Ожидалось `True` или `False`",
"Ожидалось `||` между вариантами ответа",
"Поток вывода не идёт в терминал",
"Ошибка синтаксиса в банке вопросов: {0} ({1}:{2}:{3})",
"Ошибка синтаксиса в банке вопросов: {0} (строка {1} символ {2})",
"Не удалось узнать режим консоли",
"Не удалось установить режим консоли",
}}
};
public static string? GetMessage(Message id) {
return LANGUAGES[LANGUAGE][(int)id];
}
public enum Message {
ERROR_NO_ANSWER_OPTIONS = 0,
ERROR_EXPECTED_ARROW_TOKEN,
ERROR_EXPECTED_TRUE_OR_FALSE,
ERROR_EXPECTED_ANSWER_SEPARATOR,
OUTPUT_IS_NOT_TERMINAL,
SYNTAX_ERROR_WITH_FILENAME,
SYNTAX_ERROR,
ERROR_GETCONSOLEMODE,
ERROR_SETCONSOLEMODE,
}
}
}