aso: App Store keyword fill hint and limit both count UTF-8 bytes (non-Latin locales were warned to add characters that would break the 100-byte limit)

This commit is contained in:
CRTkafa 2026-10-11 18:14:27 +00:00
parent 43daeef97f
commit 41b92dfa13
2 changed files with 14 additions and 4 deletions

View file

@ -27,10 +27,12 @@ export function auditAppleKeywords(locale: string, c: AppleCopy, appName: string
const at = `apple ${locale}`;
const kw = c.keywords ?? '';
if (!kw) return [{ level: 'error', where: at, msg: 'keywords: empty' }];
const chars = len(kw);
if (chars > 100) out.push({ level: 'error', where: at, msg: `keywords: ${chars} characters > 100` });
// App Store Connect limits the keyword field to 100 bytes (UTF-8), not characters: Cyrillic, Arabic, Hindi, Thai,
// Japanese, Korean and Chinese words take 2-3 bytes per character, so both the limit and the fill hint count bytes.
const bytes = Buffer.byteLength(kw, 'utf8');
if (bytes > 100) out.push({ level: 'error', where: at, msg: `keywords: ${bytes} bytes > 100` });
if (/,\s|\s,/.test(kw)) out.push({ level: 'error', where: at, msg: 'keywords: spaces around commas waste characters' });
if (chars < 90) out.push({ level: 'warn', where: at, msg: `keywords: ${chars}/100 used; fill at least 90 (${100 - chars} characters free)` });
if (bytes < 90) out.push({ level: 'warn', where: at, msg: `keywords: ${bytes}/100 bytes used; fill at least 90 (${100 - bytes} bytes free)` });
const terms = kw.split(',').map(t => t.trim().toLocaleLowerCase(locale)).filter(Boolean);
const seen = new Set<string>();
for (const t of terms) {