App Store Connect Calculate Character Length for Thai

I'm working with the app store connect api. I'd like to update the keywords for an appStoreVersionLocalization.

I'm getting the following error code: ENTITY_ERROR.ATTRIBUTE.INVALID.TOO_LONG

And I've tried limiting the length of the keywords using: let shortenedKeywords = String(keywords.prefix(100))

But I'm still running into the mentioned error.

The following string is valid: ตัวแก้ไข xliff, การแปลเป็นภาษาท้องถิ่น, เครื่องมือ xliff, xcode, การแปล xliff, xcloc, การแปลงข้อความ and it returns a character count of 91.

If I do something like:      let shortenedKeywords = String(keywords.prefix(80))

The error goes away.

Mostly hoping to understand why/how the character limit is calculated for Thai and if it's somehow different.

Thanks!

Full error included below:

String data is: {
 "errors" : [ {
  "id" : "d4813683-949d-4a62-b4d2-7aac248add3c",
  "status" : "409",
  "code" : "ENTITY_ERROR.ATTRIBUTE.INVALID.TOO_LONG",
  "title" : "An attribute value is too long.",
  "detail" : "Keywords for Thai cannot be longer than 100 characters.",
  "source" : {
   "pointer" : "/data/attributes/keywords"
  }
 } ]
}

This is an example request:

curl -X "PATCH" "https://api.appstoreconnect.apple.com/v1/appStoreVersionLocalizations/{id}" \
     -H 'Authorization: Bearer {token}' \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "data": {
    "type": "appStoreVersionLocalizations",
    "attributes": {
      "keywords": "ตัวแก้ไข xliff, การแปลเป็นภาษาท้องถิ่น, เครื่องมือ xliff, xcode, การแปล xliff, xcloc, การแปลงข้อความ xliff"
    },
    "id": "a4f0ba21-a8ea-4d6b-a162-bf34f36268cc"
  }
}'

Hey @joestone, Thanks for posting on the developer forums!

I am not sure if you are still encountering this error, but I did some looking, and in your posting it looks like the example string and the string in your example code are not the same exact string. I am pasting them below for reference.

ตัวแก้ไข xliff, การแปลเป็นภาษาท้องถิ่น, เครื่องมือ xliff, xcode, การแปล xliff, xcloc, การแปลงข้อความ

ตัวแก้ไข xliff, การแปลเป็นภาษาท้องถิ่น, เครื่องมือ xliff, xcode, การแปล xliff, xcloc, การแปลงข้อความ xliff

Your first string is 100 characters exactly. However, your second string that is in the API request body is 106 characters which is too long. I am able to replicate the API error when using the string that is too long, but when I use the string that is only 100 characters I am able to successfully update the Keywords text using the API. I tested using both an English and a Thai localization to make sure there was not an issue with how the characters themselves were being handled in the API body.

One thing to note that I take advantage of with Keywords in particular is that you do not need to include spaces after the commas as the string is broken apart by the comma and not a comma and a space (the space is wasted and still counts as a character). I would minify your strings to look like below.

ตัวแก้ไข xliff, การแปลเป็นภาษาท้องถิ่น, เครื่องมือ xliff, xcode, การแปล xliff, xcloc, การแปลงข้อความ <- 94 Characters

ตัวแก้ไข xliff, การแปลเป็นภาษาท้องถิ่น, เครื่องมือ xliff, xcode, การแปล xliff, xcloc, การแปลงข้อความ xliff <- 100 Characters

Both of the above strings are accepted by the API and accomplish what you are trying to do I believe.

Hopefully this helps and happy coding!

App Store Connect Calculate Character Length for Thai
 
 
Q