Adding a custom language String

  • 70 Views
  • Last Post 04 November 2017
  • Topic Is Solved
Chris posted this 04 November 2017

I have a requirement for monthly top Points Scorers.

I have added the Interface and all the supporting code. The Method works.

        /// <summary>
        /// Return an optional amount of points from the current Month, returned ordered by amount of points per user
        /// </summary>
        /// <param name="amountToTake">Number of Users to Take</param>
        /// <returns></returns>
        public Dictionary<MembershipUser, int> GetCurrentMonthsPoints(int? amountToTake)
        {
            var cacheKey = string.Concat(CacheKeys.MembershipUserPoints.StartsWith, "GetCurrentMonthsPoints-", amountToTake);
            return _cacheService.CachePerRequest(cacheKey, () =>
            {

                amountToTake = amountToTake ?? int.MaxValue;

                var date = DateTime.UtcNow;
                var start = date.Date.AddDays(-(int)date.Day);
                var end = start.AddDays(date.Day + 1);

                var results = _context.MembershipUserPoints
                    .Include(x => x.User)
                    .Where(x => x.DateAdded >= start && x.DateAdded < end)
                    .ToList();

   ...
        }

of course I have the views also:


@using System.Linq;
@model MVCForum.Website.ViewModels.HighEarnersPointViewModel
@if (Html.Settings().EnablePoints && Model.HighEarners.Any(x => x.Value > 0))
{
    <div class="side-box highearners-box">
        <h5>@Html.LanguageString("Points.ThisMonthsHighEarners")</h5>
        <ul>
            @foreach (var dict in Model.HighEarners.Where(x => x.Value > 0))
            {
                <li class="clearfix">
                    <span class="earnername">
                        <img src="@dict.Key.MemberImage(SiteConstants.Instance.GravatarLeaderboardSize)" alt="@dict.Key.UserName">
                        <a href="@dict.Key.NiceUrl">@dict.Key.UserName</a>
                    </span>
                    <span class="earneramount">
                        @dict.Value <span class="glyphicon glyphicon-sort" aria-hidden="true"></span>
                    </span>
                </li>
            }
        </ul>
    </div>
}

Now, where I am coming unstuck is the : "Points.ThisMonthsHighEarners" LanguageString...

I have added:

Points.ThisMonthsHighEarners,This Months High Earners

to the Language File: "en-GB.csv" in the directory: /Installer/

Now I must have done something terribly wrong, all I get for the heading, is: "Points.ThisMonthsHighEarners"

Please, some ideas for the correction of my mistake?

   Chris

Chris posted this 04 November 2017

Login -> Admin -> Languages -> Edit Language -> Create a new Resource Key

Add the required Resource Key: "Points.ThisMonthsHighEarners"

Or what ever your Key is.

Login -> Admin -> Languages -> Edit Language -> (Edit your newly added key)

Done, problem resolved.

   Chris

Close