0

I have created a new language "en-JP" and used the below entry in LanguageDefinitions.config file

<language id="en" region="JP" codepage="65001" encoding="utf-8" charset="iso-8859-1" icon="flags/16x16/flag_Japan.PNG" />

But when I switch an item language in Sitecore CMS, it is throwing the below error.

Error Screen

Could you please suggest to me how we can add this language and I wanted to show en-JP in my url and based on context language we're also pulling search results. Hence it is not recommended to use any alternate language code apart from "en-jp"

1

You need to register custom language in .NET and then try to define that in Sitecore.

Sample code:

string culture = "en-JP";
string name = "English (Japanese)";
  
//Create Culture & Region Info with an existing Language Culture (Eg: en-US)
CultureInfo cultureInfo = new CultureInfo("en-US");
RegionInfo regionInfo = new RegionInfo(cultureInfo.Name);
CultureAndRegionInfoBuilder cultureAndRegionInfoBuilder = new CultureAndRegionInfoBuilder(culture, CultureAndRegionModifiers.None);
cultureAndRegionInfoBuilder.LoadDataFromCultureInfo(cultureInfo);
cultureAndRegionInfoBuilder.LoadDataFromRegionInfo(regionInfo);
cultureAndRegionInfoBuilder.CultureEnglishName = cultureAndRegionInfoBuilder.CultureNativeName = name;
                  
//Register the Custom Language Culture
cultureAndRegionInfoBuilder.Register();

Check this blog that talks in detail about this - https://subbu.ca/blogs/adding-custom-language-in-sitecore/

There is a Sitecore SE post on this topic here that might be useful to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.