Languages are an important consideration in international data management. A person's language is often of great imporatance to an individual, as the many tensions between language groups on various parts of the planet attest.
Depending on how languages are defined and counted, there are between 5000 and 10000 languages spoken on the planet, many of which do not have a written form. The value a person places on the correct language being used differs, from countries where a lingua franca may acceptably be used, to those where any errors will cause immediate animosity.
Languages are spoken by people, not by countries, and every country has speakers from more than one language group, both indigenous and foreign. Defaulting to languages of a region rather than a person is bad practice and needs refinement.
Never assume that everybody in any country speaks (one of) the national language(s) of that country. Many countries have speakers of indigenous languages which are not national languages, and most have significant minorities (or, in some cases, majorities) of non-nationals speaking languages other than the offical one(s).
Note the preferred language of a person in a database, even if you are not able (at the current time) to communicate with them in that language.
Use the local form of the language. Thus, use the Flemish form for Dutch-speakers in Belgium rather than the Northern Dutch version; use Swiss-German in Switzerland, Québecois in Canada instead of Metropolitan French, and so on.
Use the language of the person, not the language of the place that person is in.
Do not use a flag to indicate a language on customer-facing pages/forms. One language, such as Spanish or English, is spoken in many countries, so one flag cannot cover them all. Equally, in many countries multiple languages are spoken, so customers clicking on a Swiss flag, for example, won't know which of the country's four official languages they will get. There are also geopolitical issues. Companies that offer websites for China and Taiwan have found the Taiwanese flag can be offensive to Chinese nationals who feel that Taiwan is not a country in its own right.