Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Dictionary <string, Dictionary <CultureInfo, string> > translations;

            using (var sqlConn = new SqlConnection(GetSqlConnectionString()))
            {
                translations = ReadTranslationsFromDataBase(sqlConn);
            }

            CreateSQLiteDB();
            using (var connection = new SqliteConnection(GetSQLiteConnectionString()))
            {
                connection.Open();
                using (var transaction = connection.BeginTransaction())
                {
                    using (var cmd = connection.CreateCommand())
                    {
                        cmd.Transaction = transaction;

                        foreach (var translation in translations)
                        {
                            foreach (var localizedTranslation in translation.Value)
                            {
                                cmd.CommandText = "INSERT INTO LocalizedStrings(Key, Culture, Value) VALUES (@key, @culture, @value)";
                                cmd.Parameters.AddWithValue("key", translation.Key);
                                cmd.Parameters.AddWithValue("culture", localizedTranslation.Key.Name);
                                cmd.Parameters.AddWithValue("value", localizedTranslation.Value);
                                cmd.ExecuteNonQuery();
                            }
                        }
                        transaction.Commit();
                    }
                }
            }

            File.Copy(SQLiteDB, $@"../../../KProcess.Ksmed.Presentation.Shell/Resources/{SQLiteDB}", true);

            var languageProvider = new SQLiteLanguageStorageProvider(GetSQLiteConnectionString());
            ILocalizationService localizationService = new LocalizationService(languageProvider);
            var excelContentBytes = localizationService.ExportLocalizedStringsToExcel();

            File.WriteAllBytes("Localization.xlsx", excelContentBytes);
        }