I am from UK, but for professional purposes I always use American spellings in APIs, even if it's an open source project and I'm the only author. It's objectively better for everybody to use a standard consistent spelling across all APIs.
For comments I use British English, I wouldn't know how to write American grammar if I tried.
But probably larger number of English speakers(including large countries in the Commonwealth like India, Pakistan, Nigeria, ) use the British spelling than American one.
I remember once getting confused when Android Studio kept pointing out that an Android SDK method I was calling didn't exist. Turned out I was using the British spelling of "colour".
That was the moment I realised most of the api calls I'd been making used the American spelling.
Generally agreed, if universality is a goal of the codebase. Eric S Raymond [0] and Jeff Atwood [1][2] have both written about the merits of the universal use of English in software development, and I think their reasoning can be extended to American English specifically. I say this as a Brit, generally fond of our proper spelling.
To expand on my proviso: if a codebase is written by and for British developers, I see little reason to use American English. For a serious international FOSS project though, American English makes the most sense.
It's costly to have a codebase undecided on proper English vs American English. If Alice writes 'initialize' and Bob writes 'initialise', it causes pain for everyone. This even applies to keywords and reserved identifiers. For instance, in Ruby, methods named 'initialize' get special treatment.
American English tends to dominate in tech, so if we have to make a choice, it's clear enough which one it should be.
Incidentally, Google [3], and apparently also Microsoft [4], agree with us.
> For comments I use British English, I wouldn't know how to write American grammar if I tried.
I think I could cope if the need arose (it hasn't for some time, for me). As you imply, the real value is in consistent spelling in the API, rather than in the comments.
For comments I use British English, I wouldn't know how to write American grammar if I tried.