prefix urls with country code

hello, we have a Django website with urlconf like urlpatterns += i18n_patterns(…) which gives
domain. com/en, domain .com/fr … I’m looking for the best way to append a prefix to URLs (country code got from user IP ) to finally get URLs like domain .com/fr-en/ or domain .com/fr/en ( here fr refers to France country code ), so something like Netflix .
my first approach is to write custom middleware to append country code, similar to LocaleMiddleware
or override LocaleMiddleware to add the country code to get /fr-en/ ( /country_code-language_code )

or any other suggestion of how to achieve this behavior.