def test_is_locale_independent(self): self.assertFalse(utils.is_locale_independent('/fr/about')) self.assertFalse(utils.is_locale_independent('/about')) self.assertTrue(utils.is_locale_independent('/media/img/logo.png')) self.assertTrue(utils.is_locale_independent('/')) self.assertTrue( utils.is_locale_independent('/test/independent/bla/bla'))
def test_is_locale_independent(self): self.assertFalse(utils.is_locale_independent('/fr/about')) self.assertFalse(utils.is_locale_independent('/about')) self.assertTrue(utils.is_locale_independent('/media/img/logo.png')) self.assertTrue(utils.is_locale_independent('/')) self.assertTrue(utils.is_locale_independent( '/test/independent/bla/bla'))
def locale_path(path, locale=''): """ Generate the localeurl-enabled path from a path without locale prefix. If the locale is empty settings.LANGUAGE_CODE is used. """ locale = utils.supported_language(locale) if not locale: locale = utils.supported_language(settings.LANGUAGE_CODE) if utils.is_locale_independent(none_locale_path(path)): return none_locale_path(path) elif utils.is_default_locale(locale) and not localeurl_settings.PREFIX_DEFAULT_LOCALE: return none_locale_path(path) elif path.find(settings.GFLUX_URL_PREFIX)!=-1: return ''.join([u'/',settings.GFLUX_URL_PREFIX, locale, path]) elif path.find(settings.APP_URL_PREFIX)!=-1: return ''.join([u'/',settings.APP_URL_PREFIX, locale, path]) elif path.find(settings.GCUSTOMER_URL_PREFIX)!=-1: return ''.join([u'/',settings.GCUSTOMER_URL_PREFIX, locale, path]) elif path.find(settings.JCB_PAY_URL_PREFIX)!=-1: return path else : return none_locale_path(path)