From 7ac8f97e961ebf0b45618013d8f66f24ff650a37 Mon Sep 17 00:00:00 2001 From: djoate <56777051+djoate@users.noreply.github.com> Date: Sat, 23 Nov 2019 01:19:23 -0500 Subject: [PATCH 01/39] Add translate filter --- _plugins/translate-filter.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 _plugins/translate-filter.rb diff --git a/_plugins/translate-filter.rb b/_plugins/translate-filter.rb new file mode 100644 index 00000000..1634bfc6 --- /dev/null +++ b/_plugins/translate-filter.rb @@ -0,0 +1,21 @@ +module Jekyll + module TranslateFilter + def translate_text(input) + text = input.strip + weblate_id = Weblate::ID.get(input) + page_language = @context.environments.first["page"]["language"] + site = @context.registers[:site] + if page_language.nil? + Weblate::SourceFile.add_entry(weblate_id, text) + + text + else + translated_string = site.data["languages"][page_language][weblate_id] + + translated_string.nil? ? text : translated_string.strip + end + end + end +end + +Liquid::Template.register_filter(Jekyll::TranslateFilter) -- 2.49.1 From 718a52be0731779277e00cb2584ab021724ea7a7 Mon Sep 17 00:00:00 2001 From: djoate <56777051+djoate@users.noreply.github.com> Date: Sat, 23 Nov 2019 15:36:49 -0500 Subject: [PATCH 02/39] Add in translate page filter --- _plugins/translate-filter.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/_plugins/translate-filter.rb b/_plugins/translate-filter.rb index 1634bfc6..8ceac24a 100644 --- a/_plugins/translate-filter.rb +++ b/_plugins/translate-filter.rb @@ -15,6 +15,16 @@ module Jekyll translated_string.nil? ? text : translated_string.strip end end + + def translate_page(page) + page_language = @context.environments.first["page"]["language"] + site = @context.registers[:site] + if page_language.nil? + page + else + "/#{page_language}#{page}" + end + end end end -- 2.49.1 From b4cc2cf5e0603731b94d744c0cf788d74e90bfec Mon Sep 17 00:00:00 2001 From: djoate <56777051+djoate@users.noreply.github.com> Date: Sat, 23 Nov 2019 15:38:18 -0500 Subject: [PATCH 03/39] Stop using capture tags for card.html includes --- _includes/card.html | 4 +-- _includes/sections/resources.html | 58 ++++++++++--------------------- weblate-source-file.yml | 25 ++++++------- 3 files changed, 32 insertions(+), 55 deletions(-) diff --git a/_includes/card.html b/_includes/card.html index a3b9803d..31ffe830 100644 --- a/_includes/card.html +++ b/_includes/card.html @@ -34,7 +34,7 @@ {% elsif include.font %} {% endif %} - {{include.description}} + {{include.description | translate_text }}
@@ -47,7 +47,7 @@
{% endif %}
{% elsif include.page %}
-
+
{% if include.moretext %}
{{include.moretext}}
{% else %}
diff --git a/_includes/sections/resources.html b/_includes/sections/resources.html
index 156fe857..baa8e79d 100644
--- a/_includes/sections/resources.html
+++ b/_includes/sections/resources.html
@@ -4,76 +4,56 @@
It's important for a website like {{ site.name }} to stay up-to-date. Keep an eye on software updates for the applications listed on our site. Follow recent news about providers that we recommend. We try our best to keep up, but we're not perfect and the internet is changing fast. If you find an error, or you think a provider should not be listed here, or a qualified service provider is missing, or a browser plugin is not the best choice anymore, or anything else... Talk to us please. You can also find us on our own Mastodon instance or on Matrix at This is a community project aiming to deliver the best information available to improve privacy online. Thank you for participating. This project needs you. {% t This is a community project aiming to deliver the best information available to improve privacy online. Thank you for participating. This project needs you. %}
{% if include.url %}
-
+
{% if include.website %}
{{include.website | translate_text }}
{% else %}
diff --git a/_includes/cardv2.html b/_includes/cardv2.html
index b9456050..b9122517 100644
--- a/_includes/cardv2.html
+++ b/_includes/cardv2.html
@@ -63,7 +63,7 @@
#general:privacytools.io.{{include.title}}
+ {{include.title | translate_text}}
{% if include.badges %}
- {{ include.title }}
+ {{ include.title | translate_text }}
{% assign badges = include.badges | split:"|" %}
{% for badge in badges %}
{% assign badge_data = badge | split:":" %}
@@ -14,15 +14,15 @@
class="badge badge-{{color}}"
{% if tooltip %}
data-toggle="tooltip"
- title="{{ tooltip }}"
- > {{text}} {{ help_icon }}
+ title="{{ tooltip | translate_text }}"
+ > {{text | translate_text}} {{ help_icon }}
{% else %}
- > {{text}}
+ > {{text | translate_text}}
{% endif %}
{% endfor %}
{% else %}
- {{ include.title }}
+ {{ include.title | translate_text }}
{% endif %}