The following might be a bit unclear, as it's a bit of a brain dump. It's mainly meant as a response to https://gerrit.wikimedia.org/r/#/c/137904/2/tests/l10n_tests.py and https://gerrit.wikimedia.org/r/#/c/137924/ and as 'food for thought'.

Basically, the question is how we can let the i18n not depend on the hardcoded 'scripts.i18n' import - this is problematic for tests, is problematic for pywikibot-installed-as-a-package (because there is no scripts.i18n then) and is problematic for third party authors (because they *have* to use the scripts.i18n folder to store their translations). I have some thoughts on this, and maybe we can make something cool out of it.

Essentially, we would want a script to be able to indicate /where/ it's i18n file is located. There's a few ways to do this, but I guess the cleanest option is something like this:

- pywikibot.i18n gets an 'I18N' class which contains the current twtranslate functions, 

- this I18N class takes a parameter: the filename of the i18n translation file (which, at some point, could also be a JSON file)
- maybe more filenames, if more translation files need to be loaded?
- or maybe a directory that contains translation files?

- we add a simple wrapper that would allow the current scripts to do something like

import pywikibot.i18n
i18n = pywikibot.i18n.forScript(__file__)

where 'forScript' does some path parsing to change __file__ (= the filename of the current file) from /path/to/original/file to /path/to/original/i18n/file

which is the setup we are currently using.

I'm not sure about backwards compatibility, but I guess we could have a pre-prepared pywikibot.i18n.twtranslate doing what it does now, via the I18N class (listing all files, maybe?)

Please let me know if this sounds like a good idea to implement.

Merlijn