Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Help Wanted! | Add Weblate i18n Support #1106

Open
JonahAragon opened this issue Aug 6, 2019 · 0 comments

Comments

@JonahAragon
Copy link
Member

commented Aug 6, 2019

Checklist

  • Homepage
  • Providers
    • Avoid US Services
    • Cloud Storage
    • DNS
    • Email
    • Hosting
    • Pastebin
    • Search
    • Social Networks
    • Social News Aggregators
    • VPN
  • Browser
    • Fingerprint
    • Browser Addons (#1138)
    • Tweaks
    • Recommendation
    • WebRTC Section
  • Software
    • Calendar/Contacts Sync
    • Notebook
    • Email Alternatives
    • Email Clients
    • File Encryption
    • File Sharing
    • Password Manager
    • Productivity
    • Real-Time Communication
      • IM
      • VoIP
      • Team Chat
    • File Sync
    • Self-Contained Notebooks
    • Self-Hosted Cloud
  • OS
  • Services Page (#1138)
  • Donate
  • Contact
  • Navbar
  • Footer (#1138)

Description

Alright. So it turns out if we use jekyll-multiple-languages-plugin and throw every single string on the site into /_i18n/en.yml we can then use our Weblate install to translate the site much easier.

The problem of course, is moving all the strings manually 😅

So that's going to be my project for now. As of df38bc4 I have successfully moved... the index page to en.yml, which took about an hour 🙄

If anyone wants to help me out with this (which I would greatly appreciate), I'm doing this work in the i18n branch of this repo. If you aren't an org member you can create Pull Requests to that branch (as opposed to master), by selecting i18n instead as the base branch in your pull request:

image

What needs to be done

Every English text string in every (HTML and Markdown) file needs to be moved to a key in en.yml. For example, lets look this line in _includes/sections/privacy-resources.html:

...
<h1 id="resources" class="anchor"><a href="#resources"><i class="fas fa-link anchor-icon"></i></a> More Privacy Resources</h1>
...

That is of course the More Privacy Resources header on the homepage. What I've done is taken the English text out of that line, and placed it en.yml, like so:

...
privacy_resources:
  header: "More Privacy Resources"
  ...

Then, back in the HTML file, I replaced the English text with {% t privacy_resources.header %} (which is a Jekyll tag saying to translate the string privacy_resources.header (from the lines above). Like so:

<h1 id="resources" class="anchor"><a href="#resources"><i class="fas fa-link anchor-icon"></i></a> {% t privacy_resources.header %}</h1>

Which really isn't that hard! It's simply time consuming to copy/paste everything into this file.

Extra note about translating {% include card.htmls

Okay, so there is one slightly more complicated bit. You can't add the {% t tags inside the {% include` tags. For example, you cannot do this:

{% include cardv2.html
title="{% t browser_addons.privacy_badger_title %}"
description="{% t browser_addons.privacy_description %}"
...

You must instead use some fancy {% capture tags, like so:

{%- capture title1 -%}{% t browser_addons.privacy_badger_title %}{%- endcapture -%}
{%- capture descr1 -%}{% t browser_addons.privacy_description %}{%- endcapture -%}

{% include cardv2.html
title=title1
description=descr1
...

It isn't too complicated, just some extra steps. Look at what I did in resources.html for a more complete example.

en.yml

You can see how I've formatted this file already, but basically it should be like:

PAGE:
  KEY: "String"

Where "Page" is the section being translated, Key is a brief description, and "String" is the English text. At the top there is also a "Global" section, for strings that are reused a bunch on different pages:

global:
  further_reading: "Further Reading"

Pretty much everything needs to go into this file, and then this file will automatically be used as the base in Weblate upon which all translations will be based on (which will be far easier).

@JonahAragon JonahAragon added this to the i18n milestone Aug 6, 2019

@JonahAragon JonahAragon self-assigned this Aug 6, 2019

@JonahAragon JonahAragon pinned this issue Aug 6, 2019

@JonahAragon JonahAragon referenced a pull request that will close this issue Aug 6, 2019

Draft

[WIP] Add Weblate Support, Move Strings to YAML Files #1105

This was referenced Aug 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.