It seems to me that English texts will get better hyphenation if the system language in macOS is set to English. Thing is, it is hard to be sure, and restarting with a new system language is cumbersome, so I haven't tested this thoroughly, but I'm reasonable sure that I've only seen "somet-hing" and similar when my system was set to Swedish.
This is on macOS Big Sur, in an NSTextView with hyphenation switched on by setting hyphenationFactor to 1 on an NSParagraphStyle object in an NSAttributedString. It is not a web view. The application is not localized, so the app language is English even when the system is set to Swedish. Setting NSAccessibilityLanguageTextAttribute to "en-US" seems to have no effect.
I'd like to know if anyone can confirm this, and if so, can anything be done about it?
From the documentation of hyphenationFactor
:
This property detects the user-selected language by examining the first item in preferredLanguages.
+[NSLocale preferredLanguages]
is called once from -[NSAttributedString lineBreakByHyphenatingBeforeIndex:withinRange:]
but before that the language is read from NSUserDefaults
with key NSHyphenationLanguage
. Setting the language with
[NSUserDefaults.standardUserDefaults setObject:@"en" forKey:@"NSHyphenationLanguage"]
seems to work but it is undocumented, so use it at your own risk.