Exemplo n.º 1
0
        private void loadFile(string fn, int cur, int total, Action <int, int> progressHandler)
        {
            int lineNum = 0;

            try {
                string msgid = null;
                foreach (var line in File.ReadLines(fn, Encoding.UTF8))
                {
                    lineNum += 1;
                    if (line.StartsWith("msgid"))
                    {
                        msgid = unescape(line);
                    }
                    else if (line.StartsWith("msgstr"))
                    {
                        if (!string.IsNullOrEmpty(msgid))
                        {
                            string msgstr = unescape(line);
                            var    tr     = new PoTranslation(msgid, msgstr, translationsByIndex.Count);
                            translationsByIndex.Add(tr);
                            translations[getKey(tr.getOriginalClean())] = tr;
                            msgid = null;
                        }
                    }
                }
                if (progressHandler != null)
                {
                    progressHandler(cur, total);
                }
            } catch (Exception ex) {
                throw new MyException("Exception when loading file: " + fn + " on line " + lineNum + ": " + ex.Message);
            }
        }
Exemplo n.º 2
0
 private void loadFile(string fn, int cur, int total, Action<int, int> progressHandler)
 {
     int lineNum = 0;
     try {
         string msgid = null;
         foreach (var line in File.ReadLines(fn, Encoding.UTF8)) {
             lineNum += 1;
             if (line.StartsWith("msgid")) {
                 msgid = unescape(line);
             } else if (line.StartsWith("msgstr")) {
                 if (!string.IsNullOrEmpty(msgid)) {
                     string msgstr = unescape(line);
                     var tr = new PoTranslation(msgid, msgstr, translationsByIndex.Count);
                     translationsByIndex.Add(tr);
                     translations[getKey(tr.getOriginalClean())] = tr;
                     msgid = null;
                 }
             }
         }
         if (progressHandler != null) {
             progressHandler(cur, total);
         }
     } catch (Exception ex) {
         throw new MyException("Exception when loading file: " + fn + " on line " + lineNum + ": " + ex.Message);
     }
 }