Skip to content

Commit 9372eed

Browse files
authored
Adapt README to clarify localization use case
1 parent 5ceed50 commit 9372eed

File tree

1 file changed

+38
-43
lines changed

1 file changed

+38
-43
lines changed

README.md

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,67 @@
1-
# mkdocs-git-revision-date-plugin
1+
# mkdocs-git-revision-date-localized-plugin
22

3-
MkDocs plugin for setting revision date from git per markdown file.
3+
[MkDocs](https://www.mkdocs.org/) plugin that displays the localized date of the last modification of a markdown file. Forked from [mkdocs-git-revision-date-plugin](https://github.com/zhaoterryy/mkdocs-git-revision-date-plugin)
44

55
## Setup
6+
67
Install the plugin using pip:
78

8-
`pip install mkdocs-git-revision-date-plugin`
9+
```bash
10+
# FIRST VERSION NOT YET PUBLISHED
11+
pip install mkdocs-git-revision-date-localized-plugin
12+
```
913

1014
Activate the plugin in `mkdocs.yml`:
15+
1116
```yaml
1217
plugins:
13-
- search
1418
- git-revision-date
1519
```
1620
17-
> **Note:** If you have no `plugins` entry in your config file yet, you'll likely also want to add the `search` plugin. MkDocs enables it by default if there is no `plugins` entry set, but now you have to enable it explicitly.
21+
## Usage
1822
19-
More information about plugins in the [MkDocs documentation][mkdocs-plugins].
23+
### In theme templates
2024
21-
## Usage
22-
The revision date will be displayed in ISO format *(YYYY-mm-dd)*.
25+
In templates you can use `page.meta.git_revision_date_localized`:
2326

24-
### Templates - `page.meta.revision_date`:
25-
#### Example
2627
```django hljs
27-
{% block footer %}
28-
<hr>
29-
<p>{% if config.copyright %}
30-
<small>{{ config.copyright }}<br></small>
28+
{% if page.meta.git_revision_date_localized %}
29+
<small><br><i>Updated {{ page.meta.git_revision_date_localized }}</i></small>
3130
{% endif %}
32-
<small>Documentation built with <a href="https://www.mkdocs.org/">MkDocs</a>.</small>
33-
{% if page.meta.revision_date %}
34-
<small><br><i>Updated {{ page.meta.revision_date }}</i></small>
35-
{% endif %}
36-
</p>
37-
{% endblock %}
3831
```
39-
More information about templates [here][mkdocs-template].
4032

41-
More information about blocks [here][mkdocs-block].
33+
### In markdown pages
4234

43-
### Markdown - `{{ git_revision_date }}`:
44-
#### Example
45-
```md
46-
Page last revised on: {{ git_revision_date }}
47-
```
48-
If using [mkdocs_macro_plugin][mkdocs-macro], it must be included after our plugin.
35+
In your markdown files you can use `{{ git_revision_date_localized }}`:
4936

50-
i.e., mkdocs.yml:
51-
```yaml
52-
plugins:
53-
- search
54-
- git-revision-date
55-
- macros
37+
```django hljs
38+
Updated {{ git_revision_date_localized_iso }}
5639
```
5740

41+
## Localization updates
5842

59-
[mkdocs-plugins]: https://www.mkdocs.org/user-guide/plugins/
60-
[mkdocs-template]: https://www.mkdocs.org/user-guide/custom-themes/#template-variables
61-
[mkdocs-block]: https://www.mkdocs.org/user-guide/styling-your-docs/#overriding-template-blocks
62-
[mkdocs-macro]: https://github.com/fralau/mkdocs_macros_plugin
43+
There are three date formats:
6344

64-
## Options
45+
- A date string format (using [babel](https://github.com/python-babel/babel/tree/master/babel)
46+
- A ISO format *(YYYY-mm-dd)*
47+
- A time ago format (using [timeago](https://github.com/hustcc/timeago)
48+
49+
```django hljs
50+
<i>Updated {{ git_revision_date_localized }}</i>
51+
<i>Updated {{ git_revision_date_localized_iso }}</i>
52+
<i>Updated {{ git_revision_date_localized_timeago }}</i>
53+
```
6554

66-
### `enabled_if_env`
55+
Output:
6756

68-
Setting this option will enable the build only if there is an environment variable set to 1. Default is not set.
57+
```
58+
Updated 28 November, 2019
59+
Updated 2019-11-28
60+
Updated 20 hours agon
61+
```
62+
63+
## Options
6964

70-
### `modify_md`
65+
### `locale`
7166

72-
Setting this option to false will disable the use of `{{ git_revision_date }}` in markdown files. Default is true.
67+
Set this option to a two letter [ISO639](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code to use a another language. This will overwrite any locale setting in `mkdocs` or your theme. If no locale is set fallback is English (`en`).

0 commit comments

Comments
 (0)