Copied to clipboard

Flag this post as spam?

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


  • Marshall Penn 79 posts 260 karma points
    Jul 13, 2023 @ 10:40
    Marshall Penn
    0

    Has anyone else had a problem with languages/locales that are not supported by windows - such as en-lb (english in Lebanon)

    I have a project which is being moved from the old way of doing languages in Umbraco whereby you have a folder/root node for each locale and no "Vary-by-culture" to a version that uses Languages in the recommended way.

    However, the old site has locales that are seemingly not available to Umbraco - or windows for that matter - for example "en-LB" (english - Lebanon), "zh-MY" (chinese - Malaysia), and the "PEM" ones - pt-PEM, fr-PEM and en-PEM.

    I am not sure how to get around this - has anyone else had this problem?

  • Huw Reddick 1749 posts 6114 karma points MVP c-trib
    Jul 13, 2023 @ 11:48
    Huw Reddick
    0

    As far as I know, none of these are offical ISO language codes so you won't be able to use them

  • Marshall Penn 79 posts 260 karma points
    Jul 17, 2023 @ 16:12
    Marshall Penn
    0

    Actually since posting that i found a 2013 free program from Microsoft called "Locale Builder" that allows you to make your own custom locales. Once you have created one and installed it into your windows PC, the custom locale will show up in a local Umbraco instance as a choice in the "Languages" section. I have not tested it on Linux/Docker/Fargate yet though ....

    enter image description here

  • Huw Reddick 1749 posts 6114 karma points MVP c-trib
    Jul 17, 2023 @ 16:23
    Huw Reddick
    0

    Fingers crossed for you, sounds like you are part way there though

  • Marshall Penn 79 posts 260 karma points
    Jul 25, 2023 @ 09:44
    Marshall Penn
    0

    Hi Huw,

    Unfortunately Locales installed using this program dont show up in windows - so it was a false hope. (English - Malaysia) is in there.

  • Marshall Penn 79 posts 260 karma points
    Aug 10, 2023 @ 10:06
    Marshall Penn
    0

    We finally got a solution using Umbraco 10 - Kindly provided by Alex Razvalinov at the agency UKAD .

    this involved intercepting the dropdown in the languages dropdown of the backoffice

    This is the interceptor code which you add in a folder within App_plugins folder using a package.manifest

    angular.module('umbraco.services').config([
        '$httpProvider',
        function ($httpProvider) {
            $httpProvider.interceptors.push([
                '$q', '$injector', 'notificationsService', function ($q, $injector, notificationsService) {
                    return {
                        'request': function (request) {
                            // Redirect any requests to built in property editor and instead redirect to our own
                            if (request.url.indexOf("/umbraco/backoffice/umbracoapi/language/GetAllCultures") === 0) {
                                request.url = "/umbraco/api/LanguagesHelper/Languages";
                            }
                            return request || $q.when(request);
                        }
                    };
                }
            ]);
        }
    ]);
    
  • Marshall Penn 79 posts 260 karma points
    Aug 10, 2023 @ 10:08
    Marshall Penn
    0
    using Microsoft.AspNetCore.Mvc;
    using System.Globalization;
    using Umbraco.Cms.Web.BackOffice.Controllers;
    using Umbraco.Cms.Web.Common.Controllers;
    namespace YOURNAMESPACEHERE.Web.Controllers {
        public class LanguagesHelperController : UmbracoApiController {
            public LanguagesHelperController() {}
            [HttpGet]
            public IActionResult Languages() {
                var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures).ToList();
                var customCultures = new List<CultureInfo>()
                {
                    new CultureInfo("en-lb"), 
                    new CultureInfo("en-jp"),
                    new CultureInfo("no-no"),
                    new CultureInfo("en-et"),
                    new CultureInfo("en-et"),
                    new CultureInfo("en-hu"),
                    new CultureInfo("en-th"),
                    new CultureInfo("en-do"),
                    new CultureInfo("es-do"),
                    new CultureInfo("zh-my"),
                    new CultureInfo("zh-cn"),
                    new CultureInfo("zh-hk"),
                    new CultureInfo("zh-tw")
                };
                cultures.AddRange(customCultures);
                var combinedCultures = cultures.DistinctBy(x => x.Name).OrderBy(x => x.EnglishName).ToDictionary(x => x.Name, x => x.EnglishName);
                return Ok(combinedCultures);
            }
        }
    }
    
  • Marshall Penn 79 posts 260 karma points
    Aug 10, 2023 @ 10:14
    Marshall Penn
    0

    Whats the trick to pasting c# code into this forum? I have been trying to paste this code for 10 minutes and it still looks sh*d!

    Thanks Huw

  • Huw Reddick 1749 posts 6114 karma points MVP c-trib
    Aug 10, 2023 @ 11:27
    Huw Reddick
    1

    paste in your code, select it all and press the {} button in the tool bar

  • Marshall Penn 79 posts 260 karma points
    Aug 10, 2023 @ 10:25
    Marshall Penn
    0

    Its important to note that some combinations of language-country will be invalid and will throw an error.

  • Marshall Penn 79 posts 260 karma points
    Aug 10, 2023 @ 13:30
    Marshall Penn
    0

    This was our package.manifest for this, you might/will probably have to change the paths etc.

    {
        "name": "Languages Interceptor",
        "version": "1.0.0",
      "javascript": [ "~/App_Plugins/LanguageHelper/languagesInterceptor.js" ]
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft