I'd like to add/enable a language, just like one would from the admin ui at /admin/config/regional/language/add
but, from code. I've found old options such as locale_add_language which no longer exists, since Drupal 5 or 6. Everything else I can find is in Tests, which seems like a bad route to take and I'm still a little new to Drupal development to understand how to make it happen, or if I should.
I'm building an app that checks the server for content in the device's language and, if it doesn't have it, the server hits Google Translate and stores the translation, and sends it on to the app. The problem is that if that language hasn't been enabled in Drupal, it doesn't store properly and effectively doesn't exist. If I pre-add the language, no problem.
Therefore, unless there's a code solution to adding a language when a new language is encountered, I'd have to enable all languages on the server. I'm not against that, but I'm also wondering if there is overhead on that, or other problems it could cause.
Thank you for any help or suggestions you might have!