Пример #1
0
        /// <summary>
        /// </summary>
        /// <param name="cultureInfo"> </param>
        public static void Update(CultureInfo cultureInfo)
        {
            var culture = cultureInfo.TwoLetterISOLanguageName;
            ResourceDictionary dictionary;

            if (Constants.Supported.Contains(culture))
            {
                switch (culture)
                {
                case "fr":
                    dictionary = French.Context();
                    break;

                case "ja":
                    dictionary = Japanese.Context();
                    break;

                case "de":
                    dictionary = German.Context();
                    break;

                case "zh":
                    dictionary = Chinese.Context();
                    break;

                default:
                    dictionary = English.Context();
                    break;
                }
            }
            else
            {
                dictionary = English.Context();
            }
            var locale = dictionary.Cast <DictionaryEntry>()
                         .ToDictionary(item => (string)item.Key, item => (string)item.Value);

            AppViewModel.Instance.Locale = locale;
            foreach (PluginInstance pluginInstance in App.Plugins.Loaded)
            {
                pluginInstance.Instance.Locale = locale;
            }
        }
Пример #2
0
        /// <summary>
        /// </summary>
        /// <param name="cultureInfo"> </param>
        public static Dictionary <string, string> Update(CultureInfo cultureInfo)
        {
            var culture = cultureInfo.TwoLetterISOLanguageName;
            Dictionary <string, string> dictionary;

            if (Constants.Supported.Contains(culture))
            {
                switch (culture)
                {
                case "fr":
                    dictionary = French.Context();
                    break;

                case "ja":
                    dictionary = Japanese.Context();
                    break;

                case "de":
                    dictionary = German.Context();
                    break;

                case "zh":
                    dictionary = Chinese.Context();
                    break;

                case "ru":
                    dictionary = Russian.Context();
                    break;

                default:
                    dictionary = English.Context();
                    break;
                }
            }
            else
            {
                dictionary = English.Context();
            }

            var e = dictionary.ToDictionary(val => val.Key, val => val.Value);

            return(e);
        }
Пример #3
0
        public override int GetHashCode()
        {
            int hashCode = 0;

            unchecked {
                if (German != null)
                {
                    hashCode += 1000000007 * German.GetHashCode();
                }
                if (English != null)
                {
                    hashCode += 1000000009 * English.GetHashCode();
                }
                if (French != null)
                {
                    hashCode += 1000000021 * French.GetHashCode();
                }
            }
            return(hashCode);
        }
Пример #4
0
        /// <summary>
        /// </summary>
        /// <param name="cultureInfo"> </param>
        public static Dictionary <string, string> Update(CultureInfo cultureInfo)
        {
            var culture = cultureInfo.TwoLetterISOLanguageName;
            ResourceDictionary dictionary;

            if (Constants.Supported.Contains(culture))
            {
                switch (culture)
                {
                case "fr":
                    dictionary = French.Context();
                    break;

                case "ja":
                    dictionary = Japanese.Context();
                    break;

                case "de":
                    dictionary = German.Context();
                    break;

                case "zh":
                    dictionary = Chinese.Context();
                    break;

                case "ru":
                    dictionary = Russian.Context();
                    break;

                default:
                    dictionary = English.Context();
                    break;
                }
            }
            else
            {
                dictionary = English.Context();
            }

            return(dictionary.Cast <DictionaryEntry>().ToDictionary(item => (string)item.Key, item => (string)item.Value));
        }
Пример #5
0
 internal void LanguagePacksReadFromCache(Halo2.CacheFile c)
 {
     if (!English.IsLoaded)
     {
         English.ReadFromCache(c);
     }
     if (!Japanese.IsLoaded)
     {
         Japanese.ReadFromCache(c);
     }
     if (!German.IsLoaded)
     {
         German.ReadFromCache(c);
     }
     if (!French.IsLoaded)
     {
         French.ReadFromCache(c);
     }
     if (!Spanish.IsLoaded)
     {
         Spanish.ReadFromCache(c);
     }
     if (!Italian.IsLoaded)
     {
         Italian.ReadFromCache(c);
     }
     if (!Korean.IsLoaded)
     {
         Korean.ReadFromCache(c);
     }
     if (!Chinese.IsLoaded)
     {
         Chinese.ReadFromCache(c);
     }
     if (!Portuguese.IsLoaded)
     {
         Portuguese.ReadFromCache(c);
     }
 }
Пример #6
0
        /// <summary>
        /// This is run each time the app runs, but won't do anything after the first run.
        /// </summary>
        public void CreateDatabase()
        {
            try
            {
                if (!File.Exists(Settings.DatabaseFile))
                {
                    string categoriesSql = "CREATE TABLE \"categories\" (" +
                                           "\"id\" INTEGER PRIMARY KEY AUTOINCREMENT," +
                                           "\"name\" TEXT NOT NULL," +
                                           "\"active\" INTEGER DEFAULT 0," +
                                           "\"inbuilt\" INTEGER DEFAULT 0)";

                    string questionsSql = "CREATE TABLE questions (" +
                                          "\"id\" INTEGER PRIMARY KEY AUTOINCREMENT," +
                                          "\"categoryid\" INTEGER," +
                                          "\"title\" TEXT," +
                                          "\"answer\" TEXT," +
                                          "\"order\" INTEGER DEFAULT 0," +
                                          "\"lastasked\" INTEGER DEFAULT 0," +
                                          "\"nextaskon\" INTEGER DEFAULT 0," +
                                          "\"previousinterval\" INTEGER DEFAULT 0," +
                                          "\"interval\" INTEGER DEFAULT 0," +
                                          "\"askcount\" INTEGER DEFAULT 0," +
                                          "\"responsequality\" INTEGER DEFAULT 0," +
                                          "\"easinessfactor\" REAL DEFAULT 0)";

                    // Create the file
                    SqliteConnection.CreateFile(Settings.DatabaseFile);

                    // And the schema
                    using (SqliteConnection connection = new SqliteConnection(Settings.DatabaseConnection))
                    {
                        connection.Open();
                        using (SqliteCommand command = new SqliteCommand(connection))
                        {
                            command.CommandText = categoriesSql;
                            command.ExecuteNonQuery();

                            command.CommandText = questionsSql;
                            command.ExecuteNonQuery();

                            // Default category
                            command.CommandText = Default.Sql();
                            command.ExecuteNonQuery();

#if GERMAN
                            command.CommandText = German.Sql();
                            command.ExecuteNonQuery();
#elif SPANISH
                            command.CommandText = Spanish.Sql();
                            command.ExecuteNonQuery();
#elif FRENCH
                            command.CommandText = French.Sql();
                            command.ExecuteNonQuery();
#endif
                        }
                    }
                }
            }
            catch (IOException ex)
            {
                Logger.Fatal("Unable to delete the database file {0}: \n{1}", Settings.DatabaseFile, ex);
                throw;
            }
            catch (SqliteException ex)
            {
                Logger.Fatal("Unable to create the database: \n{0}", ex);
                throw;
            }
        }