Search code examples
pythondjangourl-pattern

what is the purpose of solid_i18n_patterns?


i am new to python/django and i just want to know the purpose of below function/code (solid_i18n_patterns).

from django.conf.urls import url
from solid_i18n.urls import solid_i18n_patterns

urlpatterns = 
solid_i18n_patterns(<appname.views>,<urlpattern>,<anotherurlpattern>.....) 
+ 
solid_i18n_patterns(<anotherappname.views>,<urlpattern>,<anotherurlpattern>.....)

what is the purpose of solid_i18n_patterns and its arguments?


Solution

  • solid_i18n is a helper package for internationalization. Suppose you have an English website and you want to serve it also in French. By default, If you make your site bilingual, you should specify language code at the beginning of your URLs:

    www.example.com/en/* - serves English
    www.example.com/fr/* - serves French
    

    With solid_i18n_patterns, you can serve your default language without language code in URL.

    www.example.com/* - serves English (note no /en/ in URL)
    www.example.com/fr/* - serves French