How to i18n text coming from the db or from an external source

Short answer: You don’t. Not with the I18N functions. Data in the database is data that can change, and should be translated via some separate means. Data in the code is hard-coded, and doesn’t change, and can be translated via the I18N functions.

If you want to store all your translatable text in a single PHP file as an array, and then reference it from elsewhere in the code, then that works fine.