Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Multilingual support for the testimonials component #165 (#211)
Browse files Browse the repository at this point in the history
Added multilingual + multi testimonial set support

Signed-off-by: Martin Lowe <martin.lowe@eclipse-foundation.org>
  • Loading branch information
autumnfound committed Mar 22, 2021
1 parent d207557 commit 219fb00
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 2 deletions.
37 changes: 37 additions & 0 deletions exampleSite/content/components/testimonials.es.md
@@ -0,0 +1,37 @@
---
title: "Testimonials"
date: 2019-04-17T15:52:22-04:00
description: ""
categories: []
keywords: []
slug: ""
aliases: []
toc: false
draft: false
---

You can add testimonials to a markdown file using the shortcode **{{&lt; testimonials &gt;}}**

To add testimonials, create a **testimonials.yml** file in the data folder and add the code below:

~~~~
items:
-
text: Text of the testimonial 1
title: Name of the person
-
text: Text of the testimonial 2
title: Name of the person
~~~~

## Base data source

{{< testimonials >}}

## With localized copies EN + FR, w/ fallback in `./data`

{{< testimonials source="localized_testimonials">}}

## With localized copies EN + FR, w/o fallback in `./data`

{{< testimonials source="localized_testimonials_no_fallback" >}}
37 changes: 37 additions & 0 deletions exampleSite/content/components/testimonials.fr.md
@@ -0,0 +1,37 @@
---
title: "Testimonials"
date: 2019-04-17T15:52:22-04:00
description: ""
categories: []
keywords: []
slug: ""
aliases: []
toc: false
draft: false
---

You can add testimonials to a markdown file using the shortcode **{{&lt; testimonials &gt;}}**

To add testimonials, create a **testimonials.yml** file in the data folder and add the code below:

~~~~
items:
-
text: Text of the testimonial 1
title: Name of the person
-
text: Text of the testimonial 2
title: Name of the person
~~~~

## Base data source

{{< testimonials >}}

## With localized copies EN + FR, w/ fallback in `./data`

{{< testimonials source="localized_testimonials">}}

## With localized copies EN + FR, w/o fallback in `./data`

{{< testimonials source="localized_testimonials_no_fallback" >}}
12 changes: 12 additions & 0 deletions exampleSite/content/components/testimonials.md
Expand Up @@ -23,3 +23,15 @@ items:
text: Text of the testimonial 2
title: Name of the person
~~~~

## Base data source

{{< testimonials >}}

## With localized copies EN + FR, w/ fallback in `./data`

{{< testimonials source="localized_testimonials">}}

## With localized copies EN + FR, w/o fallback in `./data`

{{< testimonials source="localized_testimonials_no_fallback" >}}
10 changes: 10 additions & 0 deletions exampleSite/data/en/localized_testimonials.yml
@@ -0,0 +1,10 @@
items:
-
text: Text of the testimonial 1(localized, en)
title: Name of the person
-
text: Text of the testimonial 2
title: Name of the person
-
text: Text of the testimonial 3
title: Name of the person
10 changes: 10 additions & 0 deletions exampleSite/data/en/localized_testimonials_no_fallback.yml
@@ -0,0 +1,10 @@
items:
-
text: Text of the testimonial 1(localized no fallback, en)
title: Name of the person
-
text: Text of the testimonial 2
title: Name of the person
-
text: Text of the testimonial 3
title: Name of the person
10 changes: 10 additions & 0 deletions exampleSite/data/fr/localized_testimonials.yml
@@ -0,0 +1,10 @@
items:
-
text: Text of the testimonial 1(localized, fr)
title: Name of the person
-
text: Text of the testimonial 2
title: Name of the person
-
text: Text of the testimonial 3
title: Name of the person
10 changes: 10 additions & 0 deletions exampleSite/data/fr/localized_testimonials_no_fallback.yml
@@ -0,0 +1,10 @@
items:
-
text: Text of the testimonial 1(localized no fallback, fr)
title: Name of the person
-
text: Text of the testimonial 2
title: Name of the person
-
text: Text of the testimonial 3
title: Name of the person
10 changes: 10 additions & 0 deletions exampleSite/data/localized_testimonials.yml
@@ -0,0 +1,10 @@
items:
-
text: Text of the testimonial 1 (localized backup, no lang)
title: Name of the person
-
text: Text of the testimonial 2
title: Name of the person
-
text: Text of the testimonial 3
title: Name of the person
2 changes: 1 addition & 1 deletion exampleSite/data/testimonials.yml
@@ -1,6 +1,6 @@
items:
-
text: Text of the testimonial 1
text: Text of the testimonial 1 (loc data/testimonials.yml)
title: Name of the person
-
text: Text of the testimonial 2
Expand Down
11 changes: 10 additions & 1 deletion layouts/shortcodes/testimonials.html
Expand Up @@ -10,9 +10,18 @@
SPDX-License-Identifier: EPL-2.0
-->
<!-- Allow for alt sources and languages -->
{{ $source := .Get "source" | default "testimonials" }}
{{ $languageBase := index .Site.Data .Site.Language.Lang }}
<!-- Get the base of the testimonials by checking existence in localized section -->
{{ $base := index .Site.Data $source}}
{{ if and (ne $languageBase nil) (isset $languageBase $source) }}
{{ $base = index $languageBase $source }}
{{ end }}


<div class="row testimonial-container">
{{ range .Site.Data.testimonials.items}}
{{ range $base.items}}
<div class="col-sm-8 margin-bottom-20 testimonial-item">
<div style="background-color:#f1f3f7;" class="padding-20">
<p>"{{ .text }}"</p>
Expand Down

0 comments on commit 219fb00

Please sign in to comment.