Please don't. Flags are not languages. (
http://www.flagsarenotlanguages.com/) There are many languages which cannot be clearly distinguished with a flag icon -- for example, there are dozens of languages which could be represented by an Indian flag (Hindi, Bengali, Telugu, Urdu...), and some languages which don't have any clear flag, or whose flag could be politically complicated to display (like Catalan, Romani, or Tibetan).
Use the localized name of a language to indicate the language (e.g. English, Español, Svenska, 中文). It's unambiguous and takes very little effort to implement.