You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`locale` is a two letter [ISO639](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code that `git-revision-date-localized` uses to display dates in your preferred language.
4
+
5
+
For example:
6
+
7
+
```yaml
8
+
April 27, 2021 # `locale: en` with `type: date` (default)
9
+
April 27, 2021 13:11:28 # `locale: en` with `type: datetime`
10
+
2 weeks ago # `locale: en` with `type: timeago`
11
+
27 de marzo de 2021 # `locale: es` with `type: date`
12
+
27 de marzo de 2021 13:57:28 # `locale: es` with `type: datetime`
13
+
hace 2 semanas # `locale: es` with `type: timeago`
14
+
```
15
+
16
+
You can set the `locale` in different locations, both for your entire site and on a per-page basis. If specified multiple times `git-revision-date-localized` will use the `locale` that is most specific to a page.
17
+
18
+
Here's the order of priority:
19
+
20
+
## 1. Page locale set by the `i18n` plugin
21
+
22
+
The [mkdocs-static-i18n](https://github.com/ultrabug/mkdocs-static-i18n) plugin helps you support multiple language versions of your site. When enabled, `i18n` will add a `locale` attribute to each markdown page that `git-revision-date-localized` will use.
23
+
24
+
## 2. Page locale set by metadata
25
+
26
+
The [Metadata](https://python-markdown.github.io/extensions/meta_data/) adds the ability to attach arbitrary key-value pairs to a document via front matter written in YAML syntax before the Markdown. Enable it via mkdocs.yml:
27
+
28
+
```yaml
29
+
# mkdocs.yml
30
+
markdown_extensions:
31
+
- meta
32
+
```
33
+
34
+
If set `git-revision-date-localized` will use the `locale` key in a markdown page's frontmatter, for example:
35
+
36
+
```md
37
+
---
38
+
locale: en
39
+
---
40
+
41
+
# Page title
42
+
```
43
+
44
+
## 3. Site locale set by your theme
45
+
46
+
Some [MkDocs Themes](https://github.com/mkdocs/mkdocs/wiki/MkDocs-Themes) support [localization](https://www.mkdocs.org/user-guide/localizing-your-theme/) by setting a `locale` or `language` option. See for example the [Changing the language](https://squidfunk.github.io/mkdocs-material/setup/changing-the-language/) section of [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/).
47
+
48
+
Example:
49
+
50
+
```yaml
51
+
# mkdocs.yml
52
+
theme:
53
+
language: en
54
+
```
55
+
56
+
## 4. Site locale set by this plugin
57
+
58
+
Of course `locale` is an [option](../options.md) for this plugin also.
59
+
60
+
```yaml
61
+
plugins:
62
+
- git-revision-date-localized:
63
+
locale: en
64
+
```
65
+
66
+
## 5. Fallback locale
67
+
68
+
If no `locale` is specified anywhere, the fallback is English (`en`).
69
+
70
+
!!! info "Supported locales"
71
+
- When used in combination with `type: date` or `type: datetime`, translation is done using [babel](https://github.com/python-babel/babel) which supports [these locales](http://www.unicode.org/cldr/charts/latest/supplemental/territory_language_information.html)
72
+
73
+
- When used in combination with `type: timeago` then [timeago.js](https://github.com/hustcc/timeago.js) is added to your website, which supports [these locales](https://github.com/hustcc/timeago.js/tree/master/src/lang). If you specify a locale not supported by timeago.js, the fallback is English (`en`)
Default is `UTC`. Specify a time zone database name ([reference](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)). This option is especially relevant when using `type: datetime` and `type: iso_datetime`. Note that when using [timeago](http://timeago.yarp.com/) (with `type: timeago`) any difference in time zones between server and client will be handled automatically.
35
35
36
-
## `locale`
36
+
=== ":octicons-file-code-16: mkdocs.yml"
37
+
38
+
```yaml
39
+
plugins:
40
+
- git-revision-date-localized:
41
+
timezone: Europe/Amsterdam
42
+
```
43
+
37
44
38
-
Default is `None`. Specify a two letter [ISO639](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code to display dates in your preferred language.
45
+
## `locale`
39
46
40
-
- When not set, this plugin will look for `locale` or `language` options set in your theme. If also not set, the fallback is English (`en`)
41
-
- When used in combination with `type: date` or `type: datetime`, translation is done using [babel](https://github.com/python-babel/babel) which supports [these locales](http://www.unicode.org/cldr/charts/latest/supplemental/territory_language_information.html)
42
-
- When used in combination with `type: timeago` then [timeago.js](https://github.com/hustcc/timeago.js) is added to your website, which supports [these locales](https://github.com/hustcc/timeago.js/tree/master/src/lang). If you specify a locale not supported by timeago.js, the fallback is English (`en`)
47
+
Default is `None`. Specify a two letter [ISO639](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code to display dates in your preferred language. Note this plugin supports many different ways to [specify the locale](howto/specify-locale.md), but if not specified anywhere the fallback is English (`en`).
43
48
44
49
Example outputs:
45
50
@@ -52,14 +57,40 @@ April 27, 2021 13:11:28 # `locale: en` with `type: datetime`
52
57
hace 2 semanas # `locale: es` with `type: timeago`
53
58
```
54
59
60
+
=== ":octicons-file-code-16: mkdocs.yml"
61
+
62
+
```yaml
63
+
plugins:
64
+
- git-revision-date-localized:
65
+
locale: en
66
+
```
67
+
68
+
55
69
## `fallback_to_build_date`
56
70
57
71
Default is `false`. Enables falling back to the time when `mkdocs build` was executed *when git is not available*. This means the revision date will be incorrect, but this can be acceptable if you want your project to also successfully build in environments with no access to GIT.
58
72
73
+
=== ":octicons-file-code-16: mkdocs.yml"
74
+
75
+
```yaml
76
+
plugins:
77
+
- git-revision-date-localized:
78
+
fallback_to_build_date: true
79
+
```
80
+
81
+
59
82
## `enable_creation_date`
60
83
61
84
Default is `false` (because it has a small effect on build time). Enables a *Created* date variables, see [available-variables.md]. This will also add a created date at the bottom of each page in `mkdocs-material` as it has native support (see [overriding a theme](howto/override-a-theme.md)).
62
85
86
+
=== ":octicons-file-code-16: mkdocs.yml"
87
+
88
+
```yaml
89
+
plugins:
90
+
- git-revision-date-localized:
91
+
enable_creation_date: true
92
+
```
93
+
63
94
## `exclude`
64
95
65
96
Default is empty. Specify a list of page source paths (one per line) that should not have a revision date included (excluded from processing by this plugin). This can be useful for example to remove the revision date from the front page. The source path of a page is relative to your `docs/` folder. You can also use [globs](https://docs.python.org/3/library/glob.html) instead of full source paths. To exclude `docs/subfolder/page.md` specify in your `mkdocs.yml` a line under `exclude:` with `- subfolder/page.md`. Some examples:
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
0 commit comments