Generate always available name for a new website - #900
Conversation
sejas
left a comment
There was a problem hiding this comment.
Left a couple of suggestions.
I think adding a postfix is an improvement 💪
In addition to this, we could increase our list of default sitenames by having a really long list of adjetives produced by an LLM and then use something like sprintf( __( 'My %s Website' ), adjetive ),
| const CYRILLIC = 'а-яё'; | ||
| const ARABIC = '\\u0600-\\u06FF'; | ||
| const HEBREW = '\\u0590-\\u05FF'; | ||
| const HEREW = '\\u0590-\\u05FF'; |
There was a problem hiding this comment.
I think this change is not intentional.
| while ( usedSiteNames.includes( `${ randomName } ${ postfix }` ) ) { | ||
| postfix++; | ||
| } | ||
| return `${ randomName } ${ postfix }`; |
There was a problem hiding this comment.
Should we take into account RTL languages ? For those languages the postfix should be on the left.
There was a problem hiding this comment.
Would it make sense to always use My WordPress Website for subsequent names with the number, so user who uses all random names will keep getting My WordPress Website 1, My WordPress Website 2 and so on?
There was a problem hiding this comment.
Personally for me, it's one more good option. And I don't see any pros/cons, anyway it's more kinda "Temporary name", 99% that the user will change it to something connected with their website, unless it's testing site.
Only one good thing what I see with the current approach is that we have diversity of names 😅
So I would go with either proposed approach by me or remove all adjectives and keep only My WordPress Website ${number}. But I am ok with any approach, as long as we provide unique names.
There was a problem hiding this comment.
UPDATE, Oh, I guess you meant exactly to use only subsequent names of My WordPress Website and remove adjective options, right? If so, ignore my previous message and I think that it's good simple approach too, I don't have strong preference either to use it or keep proposed by me.
There was a problem hiding this comment.
Yes, this is what I meant. So the order would look as follows:
My WordPress Website- One of
My RANDOM Websitenames My WordPress Website 1My WordPress Website 2
This seems to be the least confusing to me.
| while ( usedSiteNames.includes( `${ randomName } ${ postfix }` ) ) { | ||
| postfix++; | ||
| } | ||
| return `${ randomName } ${ postfix }`; |
There was a problem hiding this comment.
Would it make sense to always use My WordPress Website for subsequent names with the number, so user who uses all random names will keep getting My WordPress Website 1, My WordPress Website 2 and so on?
| } | ||
|
|
||
| const randomName = siteNames[ Math.floor( Math.random() * siteNames.length ) ]; | ||
| let postfix = 1; |
There was a problem hiding this comment.
Should it be suffix instead of postfix? Or just a siteNumber to ensure it makes sense for LTR and RTL?
There was a problem hiding this comment.
Should it be suffix instead of postfix? Or just a siteNumber to ensure it makes sense for LTR and RTL?
If we make it as suffix, then it will be confusing for LTR environments, since we used to see number at the end (e.g. in MacOS, Windows).
So my opinion, we should change postfix with suffix only for RTL.
WDYT?

There was a problem hiding this comment.
My comment referred only to the variable name. postfix is the name of the mail-sending agent. I think it should be affix, instead, or even better, just siteNumber.
wojtekn
left a comment
There was a problem hiding this comment.
Works as expected. I'm just unsure if the first number should be 1 or 2, because in the end, "My WordPress Website 1" will be second site of that name. Not a big deal, though, as it's edge case.
I haven't reviewed the code here, but the commonsensical approach would be to start the counter from 2, IMO. |
Proposed Changes
When you run out of available names, there is very weird result: after clicking "Add site" button we immediately see the next:


With this PR, the generation of names is always successful (we add numeric postfix), so users don't need to do extra actions and spend time to figure out "what is going on" .
Testing Instructions
Apply the next diff:
My WordPress Websiteand create itMy Bold WebsiteandMy Bright Website