Beispiel #1
0
        private void deleteKey(bool translationsOnly)
        {
            if (info != null)
            {
                AndroidXmlChecker checker = new AndroidXmlChecker();
                checker.FolderName = Properties.Settings.Default.ValuesFolder;
                string stringId = tbxDeleteKey.Text;

                if (info.Summary.Exists(d => d.StringId == stringId))
                {
                    AndroidXmlChecker.StringData    stringData    = info.Summary.Find(d => d.StringId == stringId);
                    AndroidXmlChecker.DeleteKeyInfo deleteKeyInfo = checker.DeleteKey(stringData, translationsOnly, progressBar);
                    if (deleteKeyInfo.Error != null)
                    {
                        MessageBox.Show(
                            "Delete Key: " + stringId + "\r\n" +
                            "Delete count: " + deleteKeyInfo.Count + "\r\n" +
                            "Error: " + deleteKeyInfo.Error.ToString(),
                            "Delete Key Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show(
                            "Delete Key: " + stringId + "\r\n" +
                            "Delete count: " + deleteKeyInfo.Count,
                            "Delete Key Success",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show(
                        "Delete Key: " + stringId + "\r\n" +
                        "String id not found.",
                        "Delete Key Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show(
                    "Please run first the \"Check Android xml files\" option.",
                    "Delete Key Warning",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
            }
        }
Beispiel #2
0
        private void checkAndroid()
        {
            AndroidXmlChecker checker = new AndroidXmlChecker();

            checker.FolderName = Properties.Settings.Default.ValuesFolder;
            info = checker.Validate(progressBar);

            logClear();
            if (info.Error != null)
            {
                logException(info.Error);
            }
            else
            {
                StringBuilder sb    = new StringBuilder();
                int           count = 0;
                foreach (AndroidXmlChecker.StringData sd in info.Summary)
                {
                    bool showMissingTranslation = sd.MissingTranslation && (Properties.Settings.Default.Filter == 0 || Properties.Settings.Default.Filter == 1);
                    bool showFormatIssue        = sd.FormatIssue && (Properties.Settings.Default.Filter == 0 || Properties.Settings.Default.Filter == 2);
                    if (!showMissingTranslation && !showFormatIssue)
                    {
                        continue;
                    }
                    count++;
                    sb.Append((sb.Length == 0 ? "" : "\r\n\r\n") + sd.StringId);
                    if (showMissingTranslation)
                    {
                        bool showMissing = false;
                        bool showFound   = false;
                        if (sd.HasDefault)
                        {
                            sb.Append("\r\n" + Path.GetFileName(sd.DefaultData.FileName));
                        }
                        if (sd.IsTranslatable)
                        {
                            if (sd.HasDefault)
                            {
                                if (!sd.FoundTranslation)
                                {
                                    sb.Append("\r\nNot translated");
                                }
                                else if (sd.MissingTranslation)
                                {
                                    sb.Append("\r\nMissing translations");
                                    showMissing = true;
                                }
                            }
                            else
                            {
                                if (sd.MissingTranslation)
                                {
                                    sb.Append("\r\nNo default, missing translations");
                                    showMissing = true;
                                }
                                else if (sd.FoundTranslation)
                                {
                                    sb.Append("\r\nNo default, found translations");
                                    showFound = true;
                                }
                            }
                        }
                        else
                        {
                            sb.Append("\r\nNot translatable");
                            if (sd.FoundTranslation)
                            {
                                sb.Append(", found translations");
                                showFound = true;
                            }
                        }
                        if (showMissing)
                        {
                            sb.Append(" (" + sd.MissingTranslationCodes.Count + "): ");
                            for (int i = 0; i < sd.MissingTranslationCodes.Count; i++)
                            {
                                string code = sd.MissingTranslationCodes[i];
                                if (string.IsNullOrEmpty(code))
                                {
                                    code = "en";
                                }
                                sb.Append((i > 0 ? ", " : "") + code);
                            }
                        }
                        else if (showFound)
                        {
                            sb.Append(" (" + sd.FoundTranslationCodes.Count + "): ");
                            for (int i = 0; i < sd.FoundTranslationCodes.Count; i++)
                            {
                                sb.Append((i > 0 ? ", " : "") + sd.FoundTranslationCodes[i]);
                            }
                        }
                        if (sd.HasDefault)
                        {
                            AndroidXmlChecker.LanguageData ld = sd.Data.Find(d => String.IsNullOrEmpty(d.Code));
                            if (ld != null)
                            {
                                sb.Append("\r\n" + ld.Text + "");
                            }
                        }
                    }
                    if (showFormatIssue)
                    {
                        sb.Append("\r\nFormat issues (" + sd.FormatIssueCodes.Count + "): ");
                        //logAppendNewLine("    Format issues (" + sd.ErrorSpecifierCodes.Count + "): ");
                        for (int i = 0; i < sd.FormatIssueCodes.Count; i++)
                        {
                            string code = sd.FormatIssueCodes[i];
                            if (string.IsNullOrEmpty(code))
                            {
                                code = "en";
                            }
                            sb.Append((i > 0 ? ", " : "") + code);
                            //logAppend((i > 0 ? ", " : "") + code);
                        }
                    }
                }
                if (count > 0)
                {
                    sb.Append("\r\n==========\r\nString IDs with issues: " + count);
                    //logAppendNewLine("==========\r\nString IDs with issues: " + count);
                    if (Properties.Settings.Default.Filter == 0 || Properties.Settings.Default.Filter == 1)
                    {
                        sb.Append("\r\nLanguage codes: " + info.Codes.Count);
                        sb.Append("\r\nTips:" +
                                  "\r\n* Strings without English (en) are probably out of use." +
                                  "\r\n* Strings that are only in English are probably awaiting for translation or not supposed to be translated.");
                    }
                }
                logAppend(sb.ToString());
            }
        }