Exemple #1
0
 public override void ModifyContext(TranslationFileLoadingContext context)
 {
     if (Tag != null)
     {
         context._enabledTags.Add(Tag);
     }
 }
Exemple #2
0
 public override void ModifyContext(TranslationFileLoadingContext context)
 {
     foreach (var executable in Executables)
     {
         context._executables.Add(executable);
     }
 }
Exemple #3
0
 public override void ModifyContext(TranslationFileLoadingContext context)
 {
     foreach (var level in Levels)
     {
         context._levels.Remove(level);
     }
 }
Exemple #4
0
            public override void ModifyContext(TranslationFileLoadingContext context)
            {
                if (!Settings.EnableTranslationScoping)
                {
                    return;
                }

                context._resolutionCheck = DefaultResolutionCheck;
            }
Exemple #5
0
            public override void ModifyContext(TranslationFileLoadingContext context)
            {
                if (!Settings.EnableTranslationScoping)
                {
                    return;
                }

                foreach (var level in Levels)
                {
                    context._levels.Add(level);
                }
            }
Exemple #6
0
            public override void ModifyContext(TranslationFileLoadingContext context)
            {
                if (!Settings.EnableTranslationScoping)
                {
                    return;
                }

                foreach (var executable in Executables)
                {
                    context._executables.Remove(executable);
                }
            }
        private static void LoadTranslationsInStream(Stream stream, string fullFileName, bool isSubstitutionFile, bool isPreprocessorFile, bool isPostProcessorFile)
        {
            if (!Settings.EnableSilentMode)
            {
                XuaLogger.AutoTranslator.Debug($"Loading texts: {fullFileName}.");
            }

            var reader = new StreamReader(stream, Encoding.UTF8);
            {
                var context = new TranslationFileLoadingContext();

                string[] translations = reader.ReadToEnd().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string translatioOrDirective in translations)
                {
                    if (context.IsApplicable())
                    {
                        try
                        {
                            var kvp = TextHelper.ReadTranslationLineAndDecode(translatioOrDirective);
                            if (kvp != null)
                            {
                                string key   = kvp[0];
                                string value = kvp[1];

                                if (!string.IsNullOrEmpty(key))
                                {
                                    if (isSubstitutionFile)
                                    {
                                        if (!string.IsNullOrEmpty(value))
                                        {
                                            Settings.Replacements[key] = value;
                                        }
                                    }
                                    else if (isPreprocessorFile)
                                    {
                                        Settings.Preprocessors[key] = value;
                                    }
                                    else if (isPostProcessorFile)
                                    {
                                        Settings.Postprocessors[key] = value;
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            XuaLogger.AutoTranslator.Warn(e, $"An error occurred while reading translation: '{translatioOrDirective}'.");
                        }
                    }
                }
            }
        }
        private static void LoadTranslationsInStream(Stream stream, string fullFileName, bool isSubstitutionFile, bool isPreprocessorFile, bool isPostProcessorFile)
        {
            if (!Settings.EnableSilentMode)
            {
                XuaLogger.AutoTranslator.Debug($"Loading texts: {fullFileName}.");
            }

            var reader = new StreamReader(stream, Encoding.UTF8);
            {
                var context = new TranslationFileLoadingContext();
                var set     = new HashSet <string>();

                string[] translations = reader.ReadToEnd().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string translatioOrDirective in translations)
                {
                    if (context.IsApplicable())
                    {
                        string[] kvp = translatioOrDirective.Split(TranslationSplitters, StringSplitOptions.None);
                        if (kvp.Length == 2)
                        {
                            string key   = TextHelper.Decode(kvp[0]);
                            string value = TextHelper.Decode(kvp[1]);

                            if (!string.IsNullOrEmpty(key))
                            {
                                if (isSubstitutionFile)
                                {
                                    if (!string.IsNullOrEmpty(value))
                                    {
                                        Settings.Replacements[key] = value;
                                    }
                                }
                                else if (isPreprocessorFile)
                                {
                                    Settings.Preprocessors[key] = value;
                                }
                                else if (isPostProcessorFile)
                                {
                                    Settings.Postprocessors[key] = value;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #9
0
 public abstract void ModifyContext(TranslationFileLoadingContext context);