Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish the multilingual feature #2303

Closed
wants to merge 51 commits into from
Closed

Finish the multilingual feature #2303

wants to merge 51 commits into from

Commits on Aug 20, 2016

  1. Add multilingual support in Hugo

    Implements:
    * support to render:
      * content/post/whatever.en.md to /en/2015/12/22/whatever/index.html
      * content/post/whatever.fr.md to /fr/2015/12/22/whatever/index.html
    * gets enabled when `Multilingual:` is specified in config.
    * support having language switchers in templates, that know
      where the translated page is (with .Page.Translations)
      (when you're on /en/about/, you can have a "Francais" link pointing to
       /fr/a-propos/)
      * all translations are in the `.Page.Translations` map, including the current one.
    * easily tweak themes to support Multilingual mode
    * renders in a single swift, no need for two config files.
    
    Adds a couple of variables useful for multilingual sites
    
    Adds documentation (content/multilingual.md)
    
    Added language prefixing for all URL generation/permalinking see in the
    code base.
    
    Implements i18n. Leverages the great github.com/nicksnyder/go-i18n lib.. thanks Nick.
    * Adds "i18n" and "T" template functions..
    abourget authored and bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    132035a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ab69f6d View commit details
    Browse the repository at this point in the history
  3. Add Translations and AllTranslations methods to Page

    Will revisit Node later.
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    ace89dc View commit details
    Browse the repository at this point in the history
  4. Rename MainSites to Sites

    Having many *main* sites doesn't make much sense.
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    45368b1 View commit details
    Browse the repository at this point in the history
  5. Reset translation slice on rebuild

    Also add all translations, including the current, to the slice. We filter later.
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    ee608e3 View commit details
    Browse the repository at this point in the history
  6. Introduce HugoSites type

    And a Hugo global variable which contains the site under build.
    
    This is really needed to get some level of control of the "multiple languages" in play.
    
    There are still work related to this scattered around, but that will come.
    
    With this commit, the multilingual feature is starting to work.
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    57137dd View commit details
    Browse the repository at this point in the history
  7. Rework the i18n template func handling

    Setting the language to use when loading the language bundles just doesn't work.
    The template system is unfortanetely a global, and the last languate processed won ...
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    0cd90de View commit details
    Browse the repository at this point in the history
  8. Add Translations and AllTranslations to Node

    This commit also consolidates URLs on Node vs Page, so now .Permalink should be interoperable.
    
    Note that this implementations should be fairly short-livded, waiting for #2297, but the API should be stable.
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    a414c0b View commit details
    Browse the repository at this point in the history
  9. Move HugoSites to hugolib

    It will get more involved in the build process in a minute.
    
    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    b9e234e View commit details
    Browse the repository at this point in the history
  10. Move the Build* methods to HugoSites

    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    5101f14 View commit details
    Browse the repository at this point in the history
  11. Optimize the multilanguage build process

    Work In Progress!
    
    This commit makes a rework of the build and rebuild process to better suit a multi-site setup.
    
    This also includes a complete overhaul of the site tests. Previous these were a messy mix that
    were testing just small parts of the build chain, some of it testing code-paths not even used in
    "real life". Now all tests that depends on a built site follows the same and real production code path.
    
    See #2309
    Closes #2211
    Closes #477
    Closes #1744
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    e7efd95 View commit details
    Browse the repository at this point in the history
  12. Render the shortcodes as late as possible

    This is needed to make shortcode users happy with the new multilanguage support,
    but it will also solve many other related posts about "stuff not available in the shortcode".
    
    We will have to revisit this re the handler chain at some point, but that will be easier
    now as the integration test story has improved so much.
    
    As part of this commit, the site-building tests in page_test.go is refreshed, they now
    tests for all the rendering engines (when available), and all of them now uses the
    same code-path as used in production.
    
    Fixes #1229
    Fixes #2323
    Fixes ##1076
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    fa30293 View commit details
    Browse the repository at this point in the history
  13. Rework the multilingual docs

    And in the same go adjusted some minor parts of the language API:
    
    Add LanguagePrefix alias to Node and rename the Multilingual config section to Languages.
    
    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    a875e2d View commit details
    Browse the repository at this point in the history
  14. Redirect to main language from root

    See #2312
    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    31b31ac View commit details
    Browse the repository at this point in the history
  15. Add sitemap index for multilingual sites

    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    0cee248 View commit details
    Browse the repository at this point in the history
  16. Make the config loading testable

    This is needed to verify  #2309, but it closes a big hole in Hugo's automated tests.
    
    The loading of the config is now moved to `hugolib` and the same default settings are now used
    in production and tests.
    
    As Viper now uses Afero as its filesystem, we now can write fairly complete integration tests with ease.
    
    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    df2a13f View commit details
    Browse the repository at this point in the history
  17. Make taxonomies configurable per language

    See #2312
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    0cb0ed9 View commit details
    Browse the repository at this point in the history
  18. Get the list commands up to multi-site level

    This commit also unexports some Site methods, making it clear what the external build API really is.
    
    See #2312
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    01cf48f View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    34b19ba View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    29ccd24 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    d8e0497 View commit details
    Browse the repository at this point in the history
  22. Improve language handling in URLs

    The current "rendering language" is needed outside of Site. This commit moves the Language type to the helpers package, and then used to get correct correct language configuration in the markdownify template func.
    This commit also adds two new template funcs: relLangURL and absLangURL.
    
    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    b00623f View commit details
    Browse the repository at this point in the history
  23. Fix the shortcode ref tests

    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    eee1132 View commit details
    Browse the repository at this point in the history
  24. Fix livereload in multilingual mode

    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    cfebc29 View commit details
    Browse the repository at this point in the history
  25. Fix some corner cases in revised summary handling

    And clean up the test.
    
    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    5182241 View commit details
    Browse the repository at this point in the history
  26. Multilingual TODO-fixes, take 1

    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    3037b2d View commit details
    Browse the repository at this point in the history
  27. Make sure drafts etc. are not processed

    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    d9bcbe6 View commit details
    Browse the repository at this point in the history
  28. Make the check command work in multilingual mode

    Or: some more multilingual TODO-fixes.
    
    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    e7f0e3a View commit details
    Browse the repository at this point in the history
  29. Add parent as owner to Site

    And pull up common member vars like Tmpl and Multilinguage.
    
    Or: the final multilingual TODO-fixes.
    
    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    f42fc56 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    5fa9d17 View commit details
    Browse the repository at this point in the history
  31. Improve i18n string handling

    * Fall back to default language on missing translation file
    * Add a i18n-warnings build flag
    * If that flag is set, print a parseable and greppable string on missing translation strings
    
    See #2303
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    ae6a4fa View commit details
    Browse the repository at this point in the history
  32. Remove unused Multilingual Viper default

    See #2312
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    b7a922c View commit details
    Browse the repository at this point in the history
  33. Add IsTranslated to Node and Page

    Makes the templates simpler.
    
    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    1767750 View commit details
    Browse the repository at this point in the history
  34. Handle error in config loading

    See #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    b3ecfcd View commit details
    Browse the repository at this point in the history
  35. doc: Fix TOML vs YAML in multilang section

    Updates ##2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    d8291b7 View commit details
    Browse the repository at this point in the history
  36. Create a Node map to get proper node translations

    In a multi-language setup, before this commit the Node's Translations() method
    would return some "dummy nodes" that would point to the correct page (Permalink),
    but would not be the same as the node it points to -- it would not have the translated
    title etc.
    
    The node creation is, however, so mingled with rendering, whihc is too early to have any global state,
    so the nodes has to be split in a prepare and a render phase. This commits does that with as small
    a change as possible. This implementation is a temp solution until we fix #2297.
    
    Updates #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    1dc571b View commit details
    Browse the repository at this point in the history
  37. Add temp MULTILINGUAL version suffix to this branch

    For people having trouble building this.
    
    Now `hugo version` should print something like:
    
    ```
    Hugo Static Site Generator v0.17-MULTILINGUAL BuildDate: 2016-08-10T08:20:36+02:00
    ```
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    3dd112e View commit details
    Browse the repository at this point in the history
  38. Add data tests

    Updates #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    b54f2ff View commit details
    Browse the repository at this point in the history
  39. Fix YAML loading of multilingual config

    And some other minor fixes from code review.
    
    Updates #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    a1b2d47 View commit details
    Browse the repository at this point in the history
  40. Add JSON config to the multilanguage testing

    Updates #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    e0a2715 View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    949d8b4 View commit details
    Browse the repository at this point in the history
  42. Fix Data in multisites

    Updates #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    b7c1d5c View commit details
    Browse the repository at this point in the history
  43. Create a copy of the section node for RSS

    So the Permalink gets correct when listing translations.
    
    I have also checked the other relevant places to make sure we do not overwrite node values we need later.
    
    Pointers can be tricky, but lesson learned is: A copy is cheap.
    
    Updates #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    3834927 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    5af4bc1 View commit details
    Browse the repository at this point in the history
  45. Small adjustment to SiteInfo init

    After a visual inspection to make (pretty) sure it is correct re multiple languages.
    
    Updates #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    5b41d8f View commit details
    Browse the repository at this point in the history
  46. Set lang template globals for each site when render shortcodes

    We should get rid of these globals, but that is another month.
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    d93a863 View commit details
    Browse the repository at this point in the history
  47. Fix multilingual reload when shortcode changes

    This commit also refines the partial rebuild logic, to make sure we do not do more work than needed.
    
    Updates #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    7f2871b View commit details
    Browse the repository at this point in the history
  48. Fix site reset for benchmarks etc.

    Updates #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    a5ed858 View commit details
    Browse the repository at this point in the history
  49. Make sure the 404 node has .Data.Pages

    Updates #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    9dd7ac2 View commit details
    Browse the repository at this point in the history
  50. Add a global Reset func

    So we can do some benchmarking.
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    5c98048 View commit details
    Browse the repository at this point in the history
  51. Fix go vet 1.7 issues

    Updates #2309
    bep committed Aug 20, 2016
    Configuration menu
    Copy the full SHA
    680636c View commit details
    Browse the repository at this point in the history