Esempio n. 1
0
        private void LanguageEditorMain_Load(object sender, EventArgs e)
        {
            if (LanguageEntity.DefaultLanguage == null)
            {
                MessageBox.Show("Default language not found!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }

            DirectoryInfo di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);

            foreach (FileInfo languageFile in di.GetFiles("language.??.php"))
            {
                if (!LanguageEntity.IsValidLanguageFilename(languageFile.Name))
                {
                    continue;
                }

                try
                {
                    LanguageEntity languageEntity = LanguageEntity.Create(languageFile.Name);
                    languageEntities.Add(languageEntity);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(
                        string.Format("Cannot parse language file {0}. Error: {1}", languageFile.Name, ex.Message),
                        "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            cmbEditLanguage.Items.AddRange(languageEntities.ToArray());
            cmbEditLanguage.SelectedIndex = 0;
        }
Esempio n. 2
0
 public TranslationEntity(LanguageEntity language, string translationId, string translation, string english)
     : base(UnsanitizeTranslation(translation))
 {
     Language = language;
     SubItems.Add(UnsanitizeTranslation(english));
     SubItems.Add(translationId);
 }
Esempio n. 3
0
 public TranslationEntity(LanguageEntity language, string translationId, string translation, string english)
     : base(UnsanitizeTranslation(translation))
 {
     Language = language;
     SubItems.Add(UnsanitizeTranslation(english));
     SubItems.Add(translationId);
 }
Esempio n. 4
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            string lanquageName = tbNewLanguageName.Text.Trim();
            string languageId   = tbNewLanguageId.Text.ToLower().Trim();

            if (lanquageName.Length == 0)
            {
                MessageBox.Show(string.Format("Invalid language name \"{0}\".", lanquageName),
                                "Create", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                tbNewLanguageName.Focus();
                return;
            }

            if (languageId.Length != 2 || !Regex.IsMatch(languageId, "^[a-z]{2}$"))
            {
                MessageBox.Show(string.Format("Invalid language ID \"{0}\". Two characrets (a-z) expected.", languageId),
                                "Create", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                tbNewLanguageId.Focus();
                return;
            }

            if (languageEntities.Count(o => o.Id == languageId) > 0)
            {
                MessageBox.Show(string.Format("Language with a language ID \"{0}\" already exists.", languageId),
                                "Create", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                tbNewLanguageId.Focus();
                return;
            }

            string languageFilename = string.Format("language.{0}.php", languageId);

            using (StreamWriter sr = new StreamWriter(languageFilename, false, Encoding.UTF8))
            {
                string emptyLanguage = LanguageEntity.EmptyLanguagePhp.Replace("%LANGNAME%", lanquageName);
                emptyLanguage = emptyLanguage.Replace("%LANGPACKROWS%", string.Empty);
                sr.Write(emptyLanguage);
            }

            LanguageEntity languageEntity = LanguageEntity.Create(languageFilename);

            languageEntities.Add(languageEntity);
            cmbEditLanguage.SelectedIndex = cmbEditLanguage.Items.Add(languageEntity);

            MessageBox.Show("Language file successfully created.", "Create", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);

            tbNewLanguageName.Text = string.Empty;
            tbNewLanguageId.Text   = string.Empty;
        }
Esempio n. 5
0
        private void cmbEditLanguage_SelectedIndexChanged(object sender, EventArgs e)
        {
            lvLanguageEditor.Items.Clear();

            if (!(sender is ComboBox) || ((ComboBox)sender).SelectedIndex < 0 ||
                !(((ComboBox)sender).SelectedItem is LanguageEntity))
            {
                return;
            }

            LanguageEntity languageEntity = ((ComboBox)sender).SelectedItem as LanguageEntity;

            lvLanguageEditor.Items.AddRange(languageEntity.TranslationEntities.Values.ToArray());
            chEditLang.Text = languageEntity.Name;
        }
Esempio n. 6
0
        static LanguageEntity()
        {
            try
            {
                DefaultLanguage = Create("language.en.php");
            }
            catch (Exception)
            {
                DefaultLanguage = null;
            }

            const string resourceName = "LanguageEditor.language.EMPTY.php";
            Assembly assembly = Assembly.GetExecutingAssembly();

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    EmptyLanguagePhp = reader.ReadToEnd();
                }
            }
        }
Esempio n. 7
0
        static LanguageEntity()
        {
            try
            {
                DefaultLanguage = Create("language.en.php");
            }
            catch (Exception)
            {
                DefaultLanguage = null;
            }

            const string resourceName = "LanguageEditor.language.EMPTY.php";
            Assembly     assembly     = Assembly.GetExecutingAssembly();

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    EmptyLanguagePhp = reader.ReadToEnd();
                }
            }
        }