Using WordPress gettext functions in a library outside plugin or theme scope

WordPress doesn’t quite have a practice of localizing something that isn’t core/plugin/theme.

My educated guess would be that it will work just fine with same concepts, but you will have to write custom loading logic. Use lower level load_textdomain(), since higher level functions are meant for plugins/themes specifically.

As long as you determine and load domain translation correctly, WordPress wouldn’t care that calls are coming from the library context.