Skip to content

Conversation

@latiif
Copy link
Contributor

@latiif latiif commented May 18, 2020

Prerequisites

  • This pull request fixes a bug.
  • This pull request adds a feature.
  • This pull request introduces breaking change.

Description

Allows for customization in the internationalization files for "Posts".

If there is an entry in the i18n/ files under 'Posts' (Uppercase P), it will be used in the posts page.
If not, it will revert to what would've been displayed instead, and not create a breaking change.

NOTE While this is NOT a breaking change, we still need to update the i18n/ files for the changes to reflect.

Issues Resolved

How to change /posts page title? #70
i18n translation used in layout files #237

<section class="container list">
<h1 class="title">{{ .Title }}</h1>
<h1 class="title">
{{- if i18n .Title}}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is better to do something like this {{ title (i18n (lower .Title)) | default .Title }}. So, you should put "posts" as id in the language file. Yep, lower case.
Also, you need to translate the title inside the other define. This is the title shown in the browser tab/topbar.

- I18n files should have an entry for the original title in lowercase.
Copy link
Contributor Author

@latiif latiif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to make it more DRY by using a variable or a function definition. But I could not, Golang templates does not seem to allow global variables. Are you aware of a work-around?

@luizdepra
Copy link
Owner

luizdepra commented May 20, 2020

Nothing that I can remember, @latiif. But there is no problem with little repetitions in this case.

Thank you.

@luizdepra luizdepra merged commit e57d443 into luizdepra:master May 20, 2020
@a1x42
Copy link
Contributor

a1x42 commented May 21, 2020

@latiif other translations are capitalised when displayed e.g. my translation file contains téma for tag but on the list page for a specific tag it says Téma. For the posts translation this does not happen. could this be made consistent please?

@latiif
Copy link
Contributor Author

latiif commented May 21, 2020

You are correct. This was an oversight as I needed/tested this for Arabic which does not have lowercase/uppercase. A fix is suggested in #338.

@latiif latiif deleted the latiif/allow-posts-i18n branch May 21, 2020 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants