Skip to content

Commit 42ee0b0

Browse files
committed
Change translations approach
Instead of having each of the translations live on a separate GitHub Pages site that we link out to let’s get all of the translations inside this repository. This will make it easier for others to track and modify all translations as well as making changes that affect all translations in a single pass.
1 parent 055412a commit 42ee0b0

27 files changed

+164
-271
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ If you'd like to contribute, start by searching through the [issues](https://git
4646

4747
If you don't see your idea listed, and you think it fits into the goals of this guide, do one of the following:
4848
* **If your contribution is minor,** such as a typo fix, open a pull request.
49-
* **If your contribution is major,** such as a new guide or a [translation](docs/translations.md), start by opening an issue first. That way, other people can weigh in on the discussion before you do any work.
49+
* **If your contribution is major,** such as a new guide, start by opening an issue first. That way, other people can weigh in on the discussion before you do any work.
5050

5151
## Style guide
5252
If you're writing content, see the [style guide](./docs/styleguide.md) to help your prose match the rest of the Guides.

_articles/en-US/best-practices.md _articles/best-practices.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
locale: en-US
2+
lang: en
33
title: Best Practices for Maintainers
44
description: Making your life easier as an open source maintainer, from documenting processes to leveraging your community.
55
class: best-practices

_articles/en-US/building-community.md _articles/building-community.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
locale: en-US
2+
lang: en
33
title: Building Welcoming Communities
44
description: Building a community that encourages people to use, contribute to, and evangelize your project.
55
class: building

_articles/en-US/code-of-conduct.md _articles/code-of-conduct.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
locale: en-US
2+
lang: en
33
title: Your Code of Conduct
44
description: Facilitate healthy and constructive community behavior by adopting and enforcing a code of conduct.
55
class: coc

_articles/en-US/finding-users.md _articles/finding-users.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
locale: en-US
2+
lang: en
33
title: Finding Users for Your Project
44
description: Help your open source project grow by getting it in the hands of happy users.
55
class: finding

_articles/en-US/getting-paid.md _articles/getting-paid.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
locale: en-US
2+
lang: en
33
title: Getting Paid for Open Source Work
44
description: Sustain your work in open source by getting financial support for your time or your project.
55
class: getting-paid

_articles/en-US/how-to-contribute.md _articles/how-to-contribute.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
locale: en-US
2+
lang: en
33
title: How to Contribute to Open Source
44
description: Want to contribute to open source? A guide to making open source contributions, for first-timers and for veterans.
55
class: contribute

_articles/en-US/leadership-and-governance.md _articles/leadership-and-governance.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
locale: en-US
2+
lang: en
33
title: Leadership and Governance
44
description: Growing open source projects can benefit from formal rules for making decisions.
55
class: leadership

_articles/en-US/legal.md _articles/legal.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
locale: en-US
2+
lang: en
33
title: The Legal Side of Open Source
44
description: Everything you've ever wondered about the legal side of open source, and a few things you didn't.
55
class: legal

_articles/en-US/metrics.md _articles/metrics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
locale: en-US
2+
lang: en
33
title: Open Source Metrics
44
description: Make informed decisions to help your open source project thrive by measuring and tracking its success.
55
class: metrics

_articles/en-US/starting-a-project.md _articles/starting-a-project.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
locale: en-US
2+
lang: en
33
title: Starting an Open Source Project
44
description: Learn more about the world of open source and get ready to launch your own project.
55
class: beginners

_config.yml

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
title: "Open Source Guides"
22
description: "Learn how to launch and grow your project."
33

4-
# See: docs/translations.md
5-
locale: en-US
6-
translations:
7-
en-US:
8-
name: English (US)
9-
url: https://opensource.guide
10-
114
exclude:
125
- bin
136
- CNAME
@@ -29,7 +22,7 @@ permalink: /:path/
2922
collections:
3023
articles:
3124
output: true
32-
permalink: /:name/
25+
permalink: /:path/
3326

3427
defaults:
3528
- scope:

_data/fields.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Each piece of content has YAML front matter with these properties:
22

3-
locale:
3+
lang:
44
type: String
55

66
layout:

_data/locale/en-US.yml

-30
This file was deleted.

_data/locales/en.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
en:
2+
locale_name: English
3+
nav:
4+
about: About
5+
contribute: Contribute
6+
index:
7+
lead: Open source software is made by people just like you. Learn how to launch and grow your project.
8+
opensourcefriday: It's Friday! Invest a few hours contributing to the software you use and love
9+
article:
10+
table_of_contents: Table of Contents
11+
back_to_all_guides: Back to all guides
12+
related_guides: Related Guides
13+
footer:
14+
contribute:
15+
heading: Contribute
16+
description: Want to make a suggestion? This content is open source. Help us improve it.
17+
button: Contribute
18+
subscribe:
19+
heading: Stay in touch
20+
description: Be the first to hear about GitHub's latest open source tips and resources.
21+
label: Email Address
22+
button: Subscribe
23+
byline:
24+
# [code], [love], and [github] will be replaced by octicons
25+
format: "[code] with [love] by [github] and [friends]"
26+
# Label for code octicon
27+
code_label: code
28+
# Label for love octicon
29+
love_label: love
30+
# Label for the contributors link
31+
friends_label: friends

_includes/footer.html

+27-22
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
{% assign t = site.data.locales[page.lang][page.lang] %}
12
<footer class="bg-white border-top text-center pt-5">
23
<div class="container-lg p-responsive mx-auto">
34

45
<div class="d-flex flex-wrap flex-items-stretch">
56
<div class="col-12 col-sm-6 mb-4 col-border">
67
<div class="height-full p-5">
78
<img src="{{ "/assets/images/illos/squirrel.svg" | relative_url }}" class="little-illo mb-3" alt="squirrel illustration">
8-
<h3 class="alt-h3 mb-3">{{ site.data.locale[site.locale].footer.contribute.heading }}</h3>
9-
<p class="mb-3 p-large">{{ site.data.locale[site.locale].footer.contribute.description }}</p>
9+
<h3 class="alt-h3 mb-3">{{ t.footer.contribute.heading }}</h3>
10+
<p class="mb-3 p-large">{{ t.footer.contribute.description }}</p>
1011
<p>
1112
<a data-proofer-ignore href="https://github.com/{{ site.github.repository_nwo }}/edit/{{ site.branch }}/{{ page.path }}" class="btn btn-outline">
12-
{{ site.data.locale[site.locale].footer.contribute.button }}
13+
{{ t.footer.contribute.button }}
1314
</a>
1415
</p>
1516
</div>
@@ -20,14 +21,14 @@ <h3 class="alt-h3 mb-3">{{ site.data.locale[site.locale].footer.contribute.headi
2021
<form action="//github.us11.list-manage.com/subscribe/post?u=9d7ced8c4bbd6c2f238673f0f&amp;id=b514344ba3" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
2122
<div id="mc_embed_signup_scroll">
2223
<img src="{{ "/assets/images/illos/bird.svg" | relative_url }}" class="little-illo mb-3" alt="bird illustration">
23-
<h3 class="alt-h3 mb-3">{{ site.data.locale[site.locale].footer.subscribe.heading }}</h3>
24-
<p class="mb-3 p-large">{{ site.data.locale[site.locale].footer.subscribe.description }}</p>
24+
<h3 class="alt-h3 mb-3">{{ t.footer.subscribe.heading }}</h3>
25+
<p class="mb-3 p-large">{{ t.footer.subscribe.description }}</p>
2526

2627
<div class="mc-field-group col-12">
27-
<label for="mce-EMAIL" class="d-none">{{ site.data.locale[site.locale].footer.subscribe.label }}</label>
28-
<input type="email" placeholder="{{ site.data.locale[site.locale].footer.subscribe.label }}" name="EMAIL" class="form-input required email d-block col-10 mx-auto py-2 px-3 mb-3" id="mce-EMAIL" autocomplete="home email">
28+
<label for="mce-EMAIL" class="d-none">{{ t.footer.subscribe.label }}</label>
29+
<input type="email" placeholder="{{ t.footer.subscribe.label }}" name="EMAIL" class="form-input required email d-block col-10 mx-auto py-2 px-3 mb-3" id="mce-EMAIL" autocomplete="home email">
2930
<input type="checkbox" value="1" name="group[9617][1]" id="mce-group[9617]-9617-0" checked="checked" style="display:none">
30-
<input type="submit" value="{{ site.data.locale[site.locale].footer.subscribe.button }}" name="subscribe" id="mc-embedded-subscribe" class="btn btn-outline">
31+
<input type="submit" value="{{ t.footer.subscribe.button }}" name="subscribe" id="mc-embedded-subscribe" class="btn btn-outline">
3132
</div>
3233
<div id="mce-responses" class="clear">
3334
<div class="" id="mce-error-response" style="display:none"></div>
@@ -42,38 +43,42 @@ <h3 class="alt-h3 mb-3">{{ site.data.locale[site.locale].footer.subscribe.headin
4243
</div>
4344

4445
<div class="border-top text-gray py-5">
46+
{% if page.lang and site.data.locales.size > 1 %}
47+
<select id="language" class="float-md-left">
48+
{% assign locales = site.data.locales | sort %}
49+
{% for locale in locales %}
50+
{% assign lang = locale[0] %}
51+
{% assign locale_name = locale[1][lang].locale_name %}
52+
{% if page.lang == lang %}
53+
<option value="{{ lang }}" selected="selected">{{ locale_name }}</option>
54+
{% else %}
55+
<option value="{{ lang }}">{{ locale_name }}</option>
56+
{% endif %}
57+
{% endfor %}
58+
</select>
59+
{% endif %}
4560
<p class="float-md-right"><a class="text-gray-light text-small" href="{{ "/notices/" | relative_url }}">fine print</a></p>
4661

4762
<div>
4863
{% capture code %}
49-
{% assign code_label = site.data.locale[site.locale].footer.byline.code_label %}
64+
{% assign code_label = t.footer.byline.code_label %}
5065
<svg height="20" class="octicon octicon-code v-align-middle fill-gray mr-1" aria-label="{{ code_label }}" viewBox="0 0 14 16" version="1.1" width="17" role="img"><path d="M9.5 3L8 4.5 11.5 8 8 11.5 9.5 13 14 8 9.5 3zm-5 0L0 8l4.5 5L6 11.5 2.5 8 6 4.5 4.5 3z"></path></svg>
5166
{% endcapture %}
5267
{% capture love %}
53-
{% assign love_label = site.data.locale[site.locale].footer.byline.love_label %}
68+
{% assign love_label = t.footer.byline.love_label %}
5469
<svg height="20" class="octicon octicon-heart v-align-middle fill-gray mx-1" aria-label="{{love_label}}" viewBox="0 0 12 16" version="1.1" width="15" role="img"><path d="M11.2 3c-.52-.63-1.25-.95-2.2-1-.97 0-1.69.42-2.2 1-.51.58-.78.92-.8 1-.02-.08-.28-.42-.8-1-.52-.58-1.17-1-2.2-1-.95.05-1.69.38-2.2 1-.52.61-.78 1.28-.8 2 0 .52.09 1.52.67 2.67C1.25 8.82 3.01 10.61 6 13c2.98-2.39 4.77-4.17 5.34-5.33C11.91 6.51 12 5.5 12 5c-.02-.72-.28-1.39-.8-2.02V3z"></path></svg>
5570
{% endcapture %}
5671
{% capture github %}
5772
<svg height="20" class="octicon octicon-mark-github v-align-middle fill-gray mx-1" aria-label="GitHub" viewBox="0 0 16 16" version="1.1" width="20" role="img"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg>
5873
{% endcapture %}
5974
{% capture friends %}
60-
{% assign friends_label = site.data.locale[site.locale].footer.byline.friends_label %}
75+
{% assign friends_label = t.footer.byline.friends_label %}
6176
<a href="https://github.com/github/opensource.guide/graphs/contributors" class="text-gray">{{ friends_label }}</a>
6277
{% endcapture %}
6378

64-
{% assign byline = site.data.locale[site.locale].footer.byline.format %}
79+
{% assign byline = t.footer.byline.format %}
6580
{{ byline | replace: "[code]", code | replace: "[love]", love | replace: "[github]", github | replace: "[friends]", friends }}
6681
</div>
67-
68-
{% if site.translations.size > 1 %}
69-
<div class="text-small my-6">
70-
{% for translation in site.translations %}
71-
<a class="locale-chooser text-gray-light d-inline-block px-1"
72-
lang="{{ translation[0] }}"
73-
href="{{ page.url | prepend: translation[1].url }}?l={{ translation[0] }}">{{ translation[1].name }}</a>
74-
{% endfor %}
75-
</div>
76-
{% endif %}
7782
</div>
7883
</div>
7984
</footer>

_includes/head.html

+14
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,18 @@
55
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i" rel="stylesheet">
66
<link href="{{ "/assets/css/index.css" | relative_url }}" rel="stylesheet">
77
{% seo %}
8+
{% if page.lang and site.data.locales.size > 1 %}
9+
{% assign locales = site.data.locales | sort %}
10+
{% for locale in locales %}
11+
{% assign lang = locale[0] %}
12+
{% assign page_lang_slash = page.lang | append: '/' | prepend: '/' %}
13+
{% assign default_url = page.url | replace: page_lang_slash, '/' %}
14+
{% if lang == "en" %}
15+
<link rel="alternate" hreflang="en" href="{{ site.url }}{{ default_url }}" />
16+
<link rel="alternate" hreflang="x-default" href="{{ site.url }}{{ default_url }}" />
17+
{% else %}
18+
<link rel="alternate" hreflang="{{ lang }}" href="{{ site.url }}/{{ lang }}{{ default_url }}" />
19+
{% endif %}
20+
{% endfor %}
21+
{% endif %}
822
</head>

_includes/nav.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1+
{% assign t = site.data.locales[page.lang][page.lang] %}
12
<nav class="main-nav">
23
<div class="container-lg mx-auto clearfix">
34
<div class="float-sm-right">
45
<ul class="main-links d-flex flex-wrap flex-items-stretch border-left border-bottom border-sm-0 list-style-none">
56
<li class="d-inline-block border-right">
67
<a class="d-block p-3 p-sm-4" href="https://github.com/github/opensource.guide#readme">
7-
{{ site.data.locale[site.locale].nav.about }}
8+
{{ t.nav.about }}
89
</a>
910
</li>
1011
<li class="d-inline-block border-right">
1112
<a class="d-block p-3 p-sm-4" href="https://github.com/github/opensource.guide/blob/gh-pages/CONTRIBUTING.md">
12-
{{ site.data.locale[site.locale].nav.contribute }}
13+
{{ t.nav.contribute }}
1314
</a>
1415
</li>
1516
</ul>
1617
</div>
17-
{% if page.path != 'index.html' %}
18+
{% if page.layout != 'index' %}
1819
<div class="float-sm-left pl-3 breadcrumb">
1920
<p class="my-0 py-3 py-sm-4 text-gray">
2021
<a href="/" class="text-gray">{{ site.title }}</a>

_layouts/article.html

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: default
33
---
4-
4+
{% assign t = site.data.locales[page.lang][page.lang] %}
55
{% include nav.html %}
66

77
<header class="article-header {{ page.class }} bg-gray-light">
@@ -12,7 +12,7 @@ <h1 class="alt-h1 lh-condensed text-center mb-3">{{ page.title }}</h1>
1212
<nav class="toc mb-4 mb-md-6">
1313
<div class="card col-sm-8 col-md-4 col-lg-3 mx-auto">
1414
<a class="toc-trigger d-block text-center p-3">
15-
<span class="text-black">{{ site.data.locale[site.locale].article.table_of_contents }}</span><svg height="18" class="octicon octicon-triangle-down ml-2 fill-blue v-align-middle icon-flip" viewBox="0 0 12 16" version="1.1" width="13" role="img"><path fill-rule="evenodd" d="M0 5l6 6 6-6z"></path></svg>
15+
<span class="text-black">{{ t.article.table_of_contents }}</span><svg height="18" class="octicon octicon-triangle-down ml-2 fill-blue v-align-middle icon-flip" viewBox="0 0 12 16" version="1.1" width="13" role="img"><path fill-rule="evenodd" d="M0 5l6 6 6-6z"></path></svg>
1616
</a>
1717
<ol class="toc-list list-style-none">
1818
{% for section in page.toc %}
@@ -34,16 +34,18 @@ <h1 class="alt-h1 lh-condensed text-center mb-3">{{ page.title }}</h1>
3434
{{ content }}
3535
</div>
3636
<div class="text-center pb-4">
37-
<a class="alt-h3" href="/">Back to all guides</a>
37+
<a class="alt-h3" href="/{% if page.lang and page.lang != 'en' %}{{ page.lang | append: '/' }}{% endif %}">
38+
{{ t.article.back_to_all_guides }}
39+
</a>
3840
</div>
3941
</article>
4042

4143
{% if page.related %}
4244
<div class="container-lg p-responsive mx-auto border-top text-center pt-5">
43-
<h2 class="alt-h2">Related Guides</h2>
45+
<h2 class="alt-h2">{{ t.article.related_guides }}</h2>
4446
<div class="gutter-sm d-flex flex-wrap flex-items-stretch pb-md-6">
4547
{% for related in page.related %}
46-
{% assign article = site.articles | where: "class", related | first %}
48+
{% assign article = site.articles | where: 'lang', page.lang | where: 'class', related | first %}
4749
<div class="col-12 col-sm-9 mx-auto col-md-6 mt-4 mt-lg-5">
4850
<a href="{{ article.url | relative_url }}" class="guide-cover {{ article.class }} card height-full d-block">
4951

_layouts/default.html

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="{{ site.locale }}">
2+
<html lang="{{ page.lang }}">
33
{% include head.html %}
44
<body>
55
<main>
@@ -10,9 +10,6 @@
1010

1111
<script src="{{ "/assets/js/index.js" | relative_url }}"></script>
1212
<script type="text/javascript" src="//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js"></script>
13-
{% unless site.locale == "en-US" %}
14-
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/localization/messages_{{ site.locale | split: "-" | first }}.js"></script>
15-
{% endunless %}
1613
<script type="text/javascript">(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';}(jQuery));var $mcj = jQuery.noConflict(true);</script>
1714
</body>
1815
</html>

0 commit comments

Comments
 (0)