From a94541247500803274dd6bd726539c358172fd4c Mon Sep 17 00:00:00 2001 From: Rick Cogley Date: Wed, 8 Jul 2015 11:09:11 +0900 Subject: [PATCH] Add how-to for foreign language month names FYI @nicolinuxfr, added the month name example. --- .../tutorials/create-a-multilingual-site.md | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/content/tutorials/create-a-multilingual-site.md b/docs/content/tutorials/create-a-multilingual-site.md index 866f665b2..755827702 100644 --- a/docs/content/tutorials/create-a-multilingual-site.md +++ b/docs/content/tutorials/create-a-multilingual-site.md @@ -1,6 +1,6 @@ --- author: "Rick Cogley" -date: 2015-06-07 +date: 2015-07-08 linktitle: Multilingual Site menu: main: @@ -96,6 +96,35 @@ Now you can reference the strings in your templates. One way is to do it like in The above shows both techniques, using an `if eq` and `else if eq` to check the locale, and using `index` to pull strings from the data file that matches the locale set in the site's config file. +## Customize Dates + +At the time of this writing, Golang does not yet have support for internationalized locales, but if you do some work, you can simulate it. For example, if you want to use French month names, you can add a data file like ``data/mois.yaml`` with this content: + +~~~toml +1: "janvier" +2: "février" +3: "mars" +4: "avril" +5: "mai" +6: "juin" +7: "juillet" +8: "août" +9: "septembre" +10: "octobre" +11: "novembre" +12: "décembre" +~~~ + +... then index the non-English date names in your templates like so: + +~~~html + +~~~ + +This technique extracts the day, month and year by specifying ``.Date.Day``, ``.Date.Month``, and ``.Date.Year``, and uses the month number as a key, when indexing the month name data file. + ## Create Multilingual Content Now you can create markdown content in your languages, in the `content/en` and `content/ja` folders. The frontmatter stays the same on the key side, but the values would be set in each of the languages.