Esempio n. 1
0
        public void Init()
        {
            if (string.IsNullOrEmpty(_path))
            {
                throw GenerateException("Attempt to initilize Localization class without path.");
            }
            if (!Directory.Exists(_path))
            {
                throw GenerateException("Path \"{0}\" doesn't exist!.", _path);
            }
            List <string> files;

            try
            {
                files = Directory.GetFiles(_path, "*.txt", SearchOption.TopDirectoryOnly).ToList();
            }
            catch (Exception ex)
            {
                throw GenerateException("Can't get the files in the folder {0}.", ex, _path);
            }
            if (files.Count == 0)
            {
                throw GenerateException("No files found in the folder \"{0}\",", _path);
            }
            var original = files.FirstOrDefault(p => p.EndsWith("Language_English.txt"));

            if (string.IsNullOrEmpty(original))
            {
                throw GenerateException("English localization file not found in the folder \"{0}\"!", _path);
            }
            files.Remove(original);
            try
            {
                Original = new LocalizationFile(original, _logger);
            }
            catch (Exception ex)
            {
                throw GenerateException("Original file isn't ready. Can't procced", ex);
            }
            foreach (var file in files)
            {
                LocalizationFile lfile;
                try
                {
                    lfile = new LocalizationFile(file, _logger);
                }
                catch (Exception ex)
                {
                    _logger.PrintError("Can't initilize file \"{0}\". It won't be used. Error: {1}", file, ex.FriendlyException());
                    continue;
                }
                Available.Add(lfile);
            }
            Initilized = true;
        }
Esempio n. 2
0
 public void Init(LocalizationFile original)
 {
     Original   = original;
     Available  = new List <LocalizationFile>();
     Initilized = true;
 }