public void Clear()
 {
     mLocaEntries = new List<CLocaEntry>();
     mRowIndex = 0;
     mCellIndex = 0;
     mLangCount = 0;
     mInData = false;
     mIsInHeaderRow = false;
     mCurrentEntry = null;
 }
Esempio n. 2
0
 public void Clear()
 {
     mLocaEntries   = new List <CLocaEntry>();
     mRowIndex      = 0;
     mCellIndex     = 0;
     mLangCount     = 0;
     mInData        = false;
     mIsInHeaderRow = false;
     mCurrentEntry  = null;
 }
Esempio n. 3
0
        void ParseText()
        {
            if (mInData)
            {
                if (IsComment(mXmlReader.Value))
                {
                    return;
                }

                if (mIsInHeaderRow)
                {
                    ParseHeaderRow();
                    return;
                }

                if (mCellIndex == kKeyCellIndex)
                {
                    if (mLangCount == 0)
                    {
                        // If the language count is not yet set, test if this is the header row.
                        if (mXmlReader.Value == kHeaderRowFirstCellContent)
                        {
                            mIsInHeaderRow = true;
                            return;
                        }
                    }
                }

                if (mCellIndex == kKeyCellIndex)
                {
                    // create new entry
                    mCurrentEntry      = new CLocaEntry(mLangCount);
                    mCurrentEntry.mKey = mXmlReader.Value;
                    mLocaEntries.Add(mCurrentEntry);
                }
                else if (mCellIndex == kDescriptionCellIndex)
                {
                    // Handle Description
                    if (mCurrentEntry != null)
                    {
                        mCurrentEntry.mDescription = mXmlReader.Value;
                    }
                }
                else
                {
                    if (mCurrentEntry != null)
                    {
                        if ((mCellIndex - kFirstLanguageCellIndex) < mLangCount)
                        {
                            mCurrentEntry.mTranslations[mCellIndex - kFirstLanguageCellIndex] = mXmlReader.Value;
                        }
                    }
                }
            }
        }
        public void Parse(string pFilePath)
        {
            Clear();
            using (CsvReader csvReader = new CsvReader(new StreamReader(pFilePath), true))
            {
                var firstContentCell = ParseHeaderRow(csvReader.GetFieldHeaders(), pFilePath);
                while(csvReader.ReadNextRecord())
                {
                    if (csvReader[0].StartsWith("//") || string.IsNullOrEmpty(csvReader[firstContentCell]))
                    {
                        continue;
                    }

                    var locaEntry = new CLocaEntry(mLangCount);
                    locaEntry.mKey = csvReader[firstContentCell];
                    locaEntry.mDescription = csvReader[firstContentCell + 1];
                    for(int i = firstContentCell + 2, j = 0; i < csvReader.FieldCount; i++, j++)
                    {
                        locaEntry.mTranslations[j] = csvReader[i];
                    }
                    mLocaEntries.Add(locaEntry);
                }
            }
        }
        public void Parse(string pFilePath)
        {
            Clear();
            using (CsvReader csvReader = new CsvReader(new StreamReader(pFilePath), true))
            {
                var firstContentCell = ParseHeaderRow(csvReader.GetFieldHeaders(), pFilePath);
                while (csvReader.ReadNextRecord())
                {
                    if (csvReader[0].StartsWith("//") || string.IsNullOrEmpty(csvReader[firstContentCell]))
                    {
                        continue;
                    }

                    var locaEntry = new CLocaEntry(mLangCount);
                    locaEntry.mKey         = csvReader[firstContentCell];
                    locaEntry.mDescription = csvReader[firstContentCell + 1];
                    for (int i = firstContentCell + 2, j = 0; i < csvReader.FieldCount; i++, j++)
                    {
                        locaEntry.mTranslations[j] = csvReader[i];
                    }
                    mLocaEntries.Add(locaEntry);
                }
            }
        }
        void ParseText()
        {
            if(mInData)
            {
                if(IsComment(mXmlReader.Value))
                    return;

                if(mIsInHeaderRow)
                {
                    ParseHeaderRow();
                    return;
                }

                if(mCellIndex == kKeyCellIndex)
                {
                    if(mLangCount == 0)
                    {
                        // If the language count is not yet set, test if this is the header row.
                        if(mXmlReader.Value == kHeaderRowFirstCellContent)
                        {
                            mIsInHeaderRow = true;
                            return;
                        }
                    }
                }

                if(mCellIndex == kKeyCellIndex)
                {
                    // create new entry
                    mCurrentEntry = new CLocaEntry(mLangCount);
                    mCurrentEntry.mKey = mXmlReader.Value;
                    mLocaEntries.Add(mCurrentEntry);
                }
                else if(mCellIndex == kDescriptionCellIndex)
                {
                    // Handle Description
                    if(mCurrentEntry != null)
                        mCurrentEntry.mDescription = mXmlReader.Value;
                }
                else
                {
                    if(mCurrentEntry != null)
                    {
                        if((mCellIndex - kFirstLanguageCellIndex) < mLangCount)
                            mCurrentEntry.mTranslations[mCellIndex - kFirstLanguageCellIndex] = mXmlReader.Value;
                    }
                }
            }
        }