genxgeek
genxgeek

Reputation: 13357

How to determine locale per mime 1.0 email message

Is it possible to determine the locale (language) of an email message (MIME 1.0)? The particular use case I'm working on is trying to distinguish certain locales per email then translate accordingly per a custom smtp server.

Upvotes: 0

Views: 230

Answers (2)

tripleee
tripleee

Reputation: 189648

There is no reliable way, but for some scenarios, the precision of a language guesser like libtextcat is sufficient.

If you go down this route, notice that libtextcat ships with a very crude collection of language models which are basically just a proof of concept. LibreOffice maintains a fork libexttextcat which has proper language models, but only for Unicode. Creating your own language models isn't very hard, either.

Upvotes: 0

dave wanta
dave wanta

Reputation: 7214

Look at the charset value of the Content-Type header. Unless it's UTF-8, you can usually get an idea of the language the email was composed in.

Does that help?

Upvotes: 1

Related Questions