コード例 #1
0
        private async Task AppendLocalization(Stream stream, string culture, List <string> excludePhrases)
        {
            var dictionary = _localization.GetJavaScriptLocalizationDictionary(culture);

            if (excludePhrases.Count > 0)
            {
                var removes = new List <string>();

                foreach (var pair in dictionary)
                {
                    if (excludePhrases.Any(i => pair.Key.IndexOf(i, StringComparison.OrdinalIgnoreCase) != -1 || pair.Value.IndexOf(i, StringComparison.OrdinalIgnoreCase) != -1))
                    {
                        removes.Add(pair.Key);
                    }
                }

                foreach (var remove in removes)
                {
                    dictionary.Remove(remove);
                }
            }

            var js = "window.localizationGlossary=" + _jsonSerializer.SerializeToString(dictionary);

            var bytes = Encoding.UTF8.GetBytes(js);
            await stream.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false);
        }
コード例 #2
0
        private async Task AppendLocalization(Stream stream)
        {
            var js = "window.localizationGlossary=" + _jsonSerializer.SerializeToString(_localization.GetJavaScriptLocalizationDictionary(GetLocalizationCulture()));

            var bytes = Encoding.UTF8.GetBytes(js);
            await stream.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false);
        }