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?
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 ....
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);
}
};
}
]);
}
]);
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);
}
}
}
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?
As far as I know, none of these are offical ISO language codes so you won't be able to use them
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 ....
Fingers crossed for you, sounds like you are part way there though
Hi Huw,
Unfortunately Locales installed using this program dont show up in windows - so it was a false hope. (English - Malaysia) is in there.
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
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
paste in your code, select it all and press the
{}
button in the tool barIts important to note that some combinations of language-country will be invalid and will throw an error.
This was our package.manifest for this, you might/will probably have to change the paths etc.
is working on a reply...