WeChat, the Chinese messaging app, has apologised for translating “black foreigner” into the N-word.

It was noticed by Ann James, a black American director and actor who featured in China’s highest-grossing film ever, this summer’s Wolf Warrior 2.

Ms Jones recently texted Chinese colleagues to tell them she was running late. When Ms Jones translated their Chinese response into English using WeChat’s translation feature, it read: “The [N-word] is late.”

“I was just horrified”, Ms James, who has lived in China for five years, told news site Sixth Tone.

But a Chinese colleague assured Ms James that the original Chinese used – “hei laowai” – was a neutral phrase.

Local news outlet That’s Shanghai tested the app. It found that in some sentences the phrase “black foreigner” was translated neutrally, but when the phrase was used in a negative context, the app translated it into the N-word.

WeChat admitted the error.

"We're very sorry for the inappropriate translation”, a spokesperson told Sixth Tone.

“After receiving users' feedback, we immediately fixed the problem."

The app's translation software uses artificial intelligence. It learns how to use language in context by analysing huge volumes of material, which is why it may choose insulting language to translate negative sentences.

Ms James questioned why WeChat included material containing the N-word in its machine learning process.

“Why is that word even in the translator?”

Nearly a billion people used WeChat for chatting, shopping and gaming. It is censored by the Chinese government. Whatsapp, another messaging app which WeChat resembles, which has been blocked in China.