示例#1
0
        private static ILocalisable <string> GetString(ILocalisable <EmbedBuilder> embed)
        {
            return(new DynamicString(tr =>
            {
                var localised = embed.Localise(tr);
                var blocks = new List <string>();
                if (localised.Author != null)
                {
                    blocks.Add($"{localised.Author?.Name}\n{localised.Author?.Url}".Trim());
                }
                if (localised.Title != null)
                {
                    blocks.Add($"**{localised.Title}**".Trim());
                }
                if (localised.Description != null)
                {
                    blocks.Add(localised.Description.Trim());
                }
                if (localised.ThumbnailUrl != null)
                {
                    blocks.Add($"Thumbnail: {localised.ThumbnailUrl}".Trim());
                }
                foreach (var field in localised.Fields)
                {
                    blocks.Add($"**{field.Name.Trim()}**\n{field.Value.ToString().Trim()}");
                }
                if (localised.ImageUrl != null)
                {
                    blocks.Add(localised.ImageUrl.Trim());
                }
                blocks.Add(string.Join(" | ", new object[] { localised.Footer?.Text, localised.Timestamp }.Where(v => !string.IsNullOrWhiteSpace(v?.ToString()))).Trim());

                return string.Join("\n---------\n", blocks.Where(b => !string.IsNullOrWhiteSpace(b)).ToArray());
            }));
        }
        /// <summary>
        /// Localise the control
        /// </summary>
        public void Localise()
        {
            ILocalisable localisable = _visualisation as ILocalisable;

            if (localisable != null)
            {
                localisable.Localise();
            }
        }
示例#3
0
 private ILocalisable <string> ValueViewer(ILocalisable <string> baseValue)
 => new DynamicString(tr =>
 {
     var x = baseValue?.Localise(tr);
     if (string.IsNullOrWhiteSpace(x))
     {
         return(((LocalisedString)SettingText.NOTSET).Localise(tr));
     }
     return(x);
 });