コード例 #1
0
        private bool TryRegisterTranslation(SimpleTextTranslationCache cache, ScenarioData.Param param, int i,
                                            string calculatedModificationPath)
        {
            var key = TextResourceHelper.GetSpecializedKey(param, i, out var value);

            if (!string.IsNullOrEmpty(key))
            {
                if (cache.TryGetTranslation(key, true, out var translated))
                {
                    var result = TextResourceHelper.GetSpecializedTranslation(param, i, translated);
                    TranslationHelper.RegisterRedirectedResourceTextToPath(result, calculatedModificationPath);
                    param.Args[i] = result;
                    Logger.DebugLogDebug($"{GetType()} handled {calculatedModificationPath}");
                    return(true);
                }

                if (LanguageHelper.IsTranslatable(key))
                {
                    TranslationHelper.RegisterRedirectedResourceTextToPath(key, calculatedModificationPath);
                    if (AutoTranslatorSettings.IsDumpingRedirectedResourcesEnabled)
                    {
                        cache.AddTranslationToCache(key, value);
                    }
                }
            }

            return(false);
        }