README.rst 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. i18n subsites plugin
  2. ===================
  3. This plugin extends the translations functionality by creating i8n-ized sub-sites for the default site.
  4. It is therefore redundant with the *\*_LANG_{SAVE_AS,URL}* variables, so it disables them to prevent conflicts.
  5. What it does
  6. ------------
  7. 1. The *\*_LANG_URL* and *\*_LANG_SAVE_AS* variables are set to their normal counterparts (e.g. *ARTICLE_URL*) so they don't conflict with this scheme.
  8. 2. While building the site for *DEFAULT_LANG* the translations of pages and articles are not generated, but their relations to the original content is kept via links to them.
  9. 3. For each non-default language a "sub-site" with a modified config [#conf]_ is created [#run]_, linking the translations to the originals (if available). The configured language code is appended to the *OUTPUT_PATH* and *SITEURL* of each sub-site.
  10. If *HIDE_UNTRANSLATED_CONTENT* is True (default), content without a translation for a language is generated as hidden (for pages) or draft (for articles) for the corresponding language sub-site.
  11. .. [#conf] for each language a config override is given in the *I18N_SUBSITES* dictionary
  12. .. [#run] using a new *PELICAN_CLASS* instance and its ``run`` method, so each subsite could even have a different *PELICAN_CLASS* if specified in *I18N_SUBSITES* conf overrides.
  13. Setting it up
  14. -------------
  15. For each extra used language code a language specific variables overrides dictionary must be given (but can be empty) in the *I18N_SUBSITES* dictionary::
  16. PLUGINS = ['i18n_subsites', ...]
  17. # mapping: language_code -> conf_overrides_dict
  18. I18N_SUBSITES = {
  19. 'cz': {
  20. 'SITENAME': 'Hezkej blog',
  21. }
  22. }
  23. - The language code is the language identifier used in the *lang* metadata. It is appended to *OUTPUT_PATH* and *SITEURL* of each i18n sub-site.
  24. - The i18n-ized config overrides dictionary may specify configuration variable overrides, e.g. a different *LOCALE*, *SITENAME*, *TIMEZONE*, etc.
  25. However, it **must not** override *OUTPUT_PATH* and *SITEURL* as they are modified automatically by appending the language subpath.
  26. Most importantly, a localized [#local]_ theme can be specified in *THEME*.
  27. .. [#local] It is convenient to add language buttons to your theme in addition to the translations links.
  28. Usage notes
  29. -----------
  30. - It is **mandatory** to specify *lang* metadata for each article and page as *DEFAULT_LANG* is later changed for each sub-site.
  31. - As with the original translations functionality, *slug* metadata is used to group translations. It is therefore often
  32. convenient to compensate for this by overriding the content url (which defaults to slug) using the *url* and *save_as* metadata.
  33. Future plans
  34. ------------
  35. - Instead of specifying a different theme for each language, the ``jinja2.ext.i18n`` extension could be used.
  36. This would require some gettext and babel infrastructure.
  37. Development
  38. -----------
  39. Please file issues, pull requests at https://github.com/smartass101/pelican-plugins