Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sotiris Filippidis 286 posts 1501 karma points
    Aug 10, 2018 @ 16:13
    Sotiris Filippidis
    0

    Localization of custom Event Messages in back end

    Is there a way to localize Event Messages (former bubbles)? Like for example localize the category and message in the following:

    e.CancelOperation(new EventMessage("Error", "Can't delete this item because I don't like you.", EventMessageType.Error));
    
  • Jon R. Humphrey 164 posts 455 karma points c-trib
    Aug 10, 2018 @ 23:04
    Jon R. Humphrey
    0

    Sotiris,

    As noted on Slack, I would use a dictionary to handle the translations.

    You might want to ask Matt Brailsford about Vorto too though, that might make things easier but I don't know as I've not used it.

    Hope this helps nonetheless!

    #h5yr

    J

  • Jon R. Humphrey 164 posts 455 karma points c-trib
    Aug 11, 2018 @ 00:06
    Jon R. Humphrey
    100

    Sotiris,

    A couple of links for you, and then I'm off to bed!

    Hope these help!

    Night night!

    J

  • Sotiris Filippidis 286 posts 1501 karma points
    Aug 11, 2018 @ 12:36
    Sotiris Filippidis
    1

    Hi Jon, thanks for getting into the trouble of finding those links.

    Let's see:

    The first one is using a dictionary object to find out whether a node matches a list of values on one of its properties - there's no localization there.

    The second one, while very interesting, again has nothing to do with messages localization.

    The third one - while very interesting, it doesn't really apply to my case. I'm looking for a way to localize bubble messages that appear when events like publish etc. are hit.

    The fourth one actually got me thinking. And, surprise, I thought of a way!

    The problem is that front-end languages may not be the same as back-end languages, since the language preference in the back-end is per user and any user can pick any language for the back-end. So dictionary seemed to be out of the picture. That is, until you make the assumption that you have the same languages defined for the back and the front-end. In this case, something like the following works:

        var d = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemByKey("MyMessage");
        var literals = d.Translations.Where(x => x.Language.CultureInfo.TwoLetterISOLanguageName == System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName);
        var literal = (literals!=null) ? literals.First().Value : "My default message";
        e.CancelOperation(new EventMessage("Error", literal, EventMessageType.Error));
    

    Thanks for pointing me in the right direction!

Please Sign in or register to post replies

Write your reply to:

Draft