コード例 #1
0
        // update the translations grid so the user can manage the strings
        void updateTranslationsList()
        {
            usingLocale = Resourcer.ExistsLocale(localeCB.Text);
            if (lastWasNoLocale && !usingLocale)
            {
                return; // don't update everything if nothing changed
            }
            lastWasNoLocale = !usingLocale;

            // current locale
            string locale = usingLocale ? localeCB.Text : null;

            // current locale strings
            Dictionary <string, string> localeDict = usingLocale ?
                                                     Resourcer.GetStrings(locale) : null;

            StringResources = new List <StringResource>();
            foreach (var kvp in Resourcer.GetStrings())
            {
                if (usingLocale) // if we're using a locale, add locale values too
                {
                    string localeValue;
                    if (localeDict.TryGetValue(kvp.Key, out localeValue))
                    {
                        StringResources.Add(new StringResource(
                                                kvp.Key, kvp.Value, locale, localeValue));
                    }

                    else
                    {
                        StringResources.Add(new StringResource(
                                                kvp.Key, kvp.Value, locale, string.Empty));
                    }
                }

                else // only add string resources
                {
                    StringResources.Add(new StringResource(kvp.Key, kvp.Value));
                }
            }

            // update the source
            updateSource();

            // make sure to set the translation column (in)visible if required
            if (stringsResDGV.Columns.Count >= 2)
            {
                stringsResDGV.Columns[2].Visible = usingLocale;
            }

            checkTranslationBoxes(false);
        }
コード例 #2
0
 void delTranslationLL_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (Resourcer.ExistsLocale(localeCB.Text))
     {
         if (MessageBox.Show($"The {localeCB.Text} locale will be lost forever. Are you sure you want to continue?",
                             $"{localeCB.Text} will be lost", MessageBoxButtons.YesNo,
                             MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             // delete the strings resources file and reload the locales
             Resourcer.DeleteStrings(localeCB.Text);
             statusCSL.SetStatus($"The locale {localeCB.Text} have been deleted from disk");
             loadLocales();
         }
     }
 }