1

The requirement is to be able to create a Sitecore item with Chinese or Japanese characters in the item name. When I try to create an item with the name "美国律师协会" It shows an error that

'美国律师协会' is not a valid name.

I tried to change ItemNameValidation setting in Sitecore.config from

value="^[\w*$][\w\s-$]*((\d{1,})){0,1}$"

to

value="^[\p{L}\w*$][\p{L}\w\s-$]*((\d{1,})){0,1}$

"

But it is not working, Is there any solution for it ??

2
  • 1
    Are you certain you want the actual item names to be in these characters? normally, one would use the Display Name of items to lokalize them
    – Mark Cassidy
    Commented May 16 at 14:04
  • Yes, We are using a separate portal to create items remotely without using Sitecore. In this particular scenario, we can only pass a string that would be the item name as well as a field's value in that item.
    – Vinesh
    Commented May 16 at 14:14

4 Answers 4

2

You can refer below regex to allow item names in Chinese as well as Japanese characters.

^[\u4E00-\u9FFF]|[\u3040-\u30FF\u31F0-\u31FF\uFF00-\uFFEF]|[\w\*\$][\w\s\-\$]*(\(\d{1,}\)){0,1}$

This will allow items to be created as below.

enter image description here

Note: This regex will also allow English characters in addition to alphanumeric characters in Japanese and Chinese.

Hope this helps!!!

3

I tried with this Regex expression and it worked

Please try it and let me know

value="^[\u4E00-\u9FFF\w\*\$][\u4E00-\u9FFF\w\s\-\$]*(\(\d{1,}\)){0,1}$"

enter image description here

This method defines a range of Unicode code points commonly used in Chinese and Japanese character sets.

This wont break the existing Sitecore regex which is "^[\w\*\$][\w\s\-\$]*(\(\d{1,}\)){0,1}$". I have just added "\u4E00-\u9FFF" in front of both the regexes.

Hope this helps!!!

1

Normally, creating items in a different language is not a recommended way. However, you can use Display Name field to populate the localize values.

To meet your requirement you need to apply a patch to allow special characters in item name.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>    
      <setting name="ItemNameValidation">
        <patch:attribute name="value">^.*$</patch:attribute>
      </setting>
   </settings>
  </sitecore>
</configuration>

I tried it and it works for me.

enter image description here

Hope it helps!

1

Use this patch file and it should work for you.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>    
      <setting name="ItemNameValidation">
        <patch:attribute name="value">^.*$</patch:attribute>
      </setting>
   </settings>
  </sitecore>
</configuration>

According to this regex .* matches any character. And you will be able to create items. Here is the screenshot.

enter image description here

But OOTB you can use the Display Name to show the name like this.

enter image description here

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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