From 42ee0b011761ba6908f7014f3e24169a0d84c6b5 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 13 Feb 2018 13:55:44 +0000 Subject: [PATCH] Change translations approach MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- CONTRIBUTING.md | 2 +- _articles/{en-US => }/best-practices.md | 2 +- _articles/{en-US => }/building-community.md | 2 +- _articles/{en-US => }/code-of-conduct.md | 2 +- _articles/{en-US => }/finding-users.md | 2 +- _articles/{en-US => }/getting-paid.md | 2 +- _articles/{en-US => }/how-to-contribute.md | 2 +- .../{en-US => }/leadership-and-governance.md | 2 +- _articles/{en-US => }/legal.md | 2 +- _articles/{en-US => }/metrics.md | 2 +- _articles/{en-US => }/starting-a-project.md | 2 +- _config.yml | 9 +-- _data/fields.yml | 2 +- _data/locale/en-US.yml | 30 ---------- _data/locales/en.yml | 31 ++++++++++ _includes/footer.html | 49 ++++++++------- _includes/head.html | 14 +++++ _includes/nav.html | 7 ++- _layouts/article.html | 12 ++-- _layouts/default.html | 5 +- _layouts/index.html | 50 ++++++++++++++++ assets/js/locale.js | 47 +++------------ docs/templates/translation-issue-template.md | 24 -------- docs/translations.md | 23 ++------ index.html | 50 +--------------- notices.md | 1 + script/sync-translation | 59 ------------------- 27 files changed, 164 insertions(+), 271 deletions(-) rename _articles/{en-US => }/best-practices.md (99%) rename _articles/{en-US => }/building-community.md (99%) rename _articles/{en-US => }/code-of-conduct.md (99%) rename _articles/{en-US => }/finding-users.md (99%) rename _articles/{en-US => }/getting-paid.md (99%) rename _articles/{en-US => }/how-to-contribute.md (99%) rename _articles/{en-US => }/leadership-and-governance.md (99%) rename _articles/{en-US => }/legal.md (99%) rename _articles/{en-US => }/metrics.md (99%) rename _articles/{en-US => }/starting-a-project.md (99%) delete mode 100644 _data/locale/en-US.yml create mode 100644 _data/locales/en.yml create mode 100644 _layouts/index.html delete mode 100644 docs/templates/translation-issue-template.md delete mode 100755 script/sync-translation diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6843466447b..76f630e901e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,7 @@ If you'd like to contribute, start by searching through the [issues](https://git If you don't see your idea listed, and you think it fits into the goals of this guide, do one of the following: * **If your contribution is minor,** such as a typo fix, open a pull request. -* **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. +* **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. ## Style guide If you're writing content, see the [style guide](./docs/styleguide.md) to help your prose match the rest of the Guides. diff --git a/_articles/en-US/best-practices.md b/_articles/best-practices.md similarity index 99% rename from _articles/en-US/best-practices.md rename to _articles/best-practices.md index ec8390dcc43..c7ff8b7f8b0 100644 --- a/_articles/en-US/best-practices.md +++ b/_articles/best-practices.md @@ -1,5 +1,5 @@ --- -locale: en-US +lang: en title: Best Practices for Maintainers description: Making your life easier as an open source maintainer, from documenting processes to leveraging your community. class: best-practices diff --git a/_articles/en-US/building-community.md b/_articles/building-community.md similarity index 99% rename from _articles/en-US/building-community.md rename to _articles/building-community.md index 906bb9a3c17..03839ac0a06 100644 --- a/_articles/en-US/building-community.md +++ b/_articles/building-community.md @@ -1,5 +1,5 @@ --- -locale: en-US +lang: en title: Building Welcoming Communities description: Building a community that encourages people to use, contribute to, and evangelize your project. class: building diff --git a/_articles/en-US/code-of-conduct.md b/_articles/code-of-conduct.md similarity index 99% rename from _articles/en-US/code-of-conduct.md rename to _articles/code-of-conduct.md index 7be06a4bfef..432ebad723c 100644 --- a/_articles/en-US/code-of-conduct.md +++ b/_articles/code-of-conduct.md @@ -1,5 +1,5 @@ --- -locale: en-US +lang: en title: Your Code of Conduct description: Facilitate healthy and constructive community behavior by adopting and enforcing a code of conduct. class: coc diff --git a/_articles/en-US/finding-users.md b/_articles/finding-users.md similarity index 99% rename from _articles/en-US/finding-users.md rename to _articles/finding-users.md index 4edfadef021..a2202b95d5c 100644 --- a/_articles/en-US/finding-users.md +++ b/_articles/finding-users.md @@ -1,5 +1,5 @@ --- -locale: en-US +lang: en title: Finding Users for Your Project description: Help your open source project grow by getting it in the hands of happy users. class: finding diff --git a/_articles/en-US/getting-paid.md b/_articles/getting-paid.md similarity index 99% rename from _articles/en-US/getting-paid.md rename to _articles/getting-paid.md index 243508dbf41..8f3a0779f4c 100644 --- a/_articles/en-US/getting-paid.md +++ b/_articles/getting-paid.md @@ -1,5 +1,5 @@ --- -locale: en-US +lang: en title: Getting Paid for Open Source Work description: Sustain your work in open source by getting financial support for your time or your project. class: getting-paid diff --git a/_articles/en-US/how-to-contribute.md b/_articles/how-to-contribute.md similarity index 99% rename from _articles/en-US/how-to-contribute.md rename to _articles/how-to-contribute.md index 0e58307de8f..4ef611e753a 100644 --- a/_articles/en-US/how-to-contribute.md +++ b/_articles/how-to-contribute.md @@ -1,5 +1,5 @@ --- -locale: en-US +lang: en title: How to Contribute to Open Source description: Want to contribute to open source? A guide to making open source contributions, for first-timers and for veterans. class: contribute diff --git a/_articles/en-US/leadership-and-governance.md b/_articles/leadership-and-governance.md similarity index 99% rename from _articles/en-US/leadership-and-governance.md rename to _articles/leadership-and-governance.md index 39ae5119163..4626ecf8e80 100644 --- a/_articles/en-US/leadership-and-governance.md +++ b/_articles/leadership-and-governance.md @@ -1,5 +1,5 @@ --- -locale: en-US +lang: en title: Leadership and Governance description: Growing open source projects can benefit from formal rules for making decisions. class: leadership diff --git a/_articles/en-US/legal.md b/_articles/legal.md similarity index 99% rename from _articles/en-US/legal.md rename to _articles/legal.md index 767ca2f4c18..2b69631a664 100644 --- a/_articles/en-US/legal.md +++ b/_articles/legal.md @@ -1,5 +1,5 @@ --- -locale: en-US +lang: en title: The Legal Side of Open Source description: Everything you've ever wondered about the legal side of open source, and a few things you didn't. class: legal diff --git a/_articles/en-US/metrics.md b/_articles/metrics.md similarity index 99% rename from _articles/en-US/metrics.md rename to _articles/metrics.md index 597594dff2b..43d0729a50b 100644 --- a/_articles/en-US/metrics.md +++ b/_articles/metrics.md @@ -1,5 +1,5 @@ --- -locale: en-US +lang: en title: Open Source Metrics description: Make informed decisions to help your open source project thrive by measuring and tracking its success. class: metrics diff --git a/_articles/en-US/starting-a-project.md b/_articles/starting-a-project.md similarity index 99% rename from _articles/en-US/starting-a-project.md rename to _articles/starting-a-project.md index 7c2b369d013..9cdf0ed5a10 100644 --- a/_articles/en-US/starting-a-project.md +++ b/_articles/starting-a-project.md @@ -1,5 +1,5 @@ --- -locale: en-US +lang: en title: Starting an Open Source Project description: Learn more about the world of open source and get ready to launch your own project. class: beginners diff --git a/_config.yml b/_config.yml index af86874fb79..95f9a39fb8f 100644 --- a/_config.yml +++ b/_config.yml @@ -1,13 +1,6 @@ title: "Open Source Guides" description: "Learn how to launch and grow your project." -# See: docs/translations.md -locale: en-US -translations: - en-US: - name: English (US) - url: https://opensource.guide - exclude: - bin - CNAME @@ -29,7 +22,7 @@ permalink: /:path/ collections: articles: output: true - permalink: /:name/ + permalink: /:path/ defaults: - scope: diff --git a/_data/fields.yml b/_data/fields.yml index a51228eb838..09cc4bb15cb 100644 --- a/_data/fields.yml +++ b/_data/fields.yml @@ -1,6 +1,6 @@ # Each piece of content has YAML front matter with these properties: -locale: +lang: type: String layout: diff --git a/_data/locale/en-US.yml b/_data/locale/en-US.yml deleted file mode 100644 index 84bb3903576..00000000000 --- a/_data/locale/en-US.yml +++ /dev/null @@ -1,30 +0,0 @@ -nav: - about: About - contribute: Contribute - -index: - lead: Open source software is made by people just like you. Learn how to launch and grow your project. - opensourcefriday: It's Friday! Invest a few hours contributing to the software you use and love - -article: - table_of_contents: Table of Contents - -footer: - contribute: - heading: Contribute - description: Want to make a suggestion? This content is open source. Help us improve it. - button: Contribute - subscribe: - heading: Stay in touch - description: Be the first to hear about GitHub's latest open source tips and resources. - label: Email Address - button: Subscribe - byline: - # [code], [love], and [github] will be replaced by octicons - format: "[code] with [love] by [github] and [friends]" - # Label for code octicon - code_label: code - # Label for love octicon - love_label: love - # Label for the contributors link - friends_label: friends diff --git a/_data/locales/en.yml b/_data/locales/en.yml new file mode 100644 index 00000000000..8123455687e --- /dev/null +++ b/_data/locales/en.yml @@ -0,0 +1,31 @@ +en: + locale_name: English + nav: + about: About + contribute: Contribute + index: + lead: Open source software is made by people just like you. Learn how to launch and grow your project. + opensourcefriday: It's Friday! Invest a few hours contributing to the software you use and love + article: + table_of_contents: Table of Contents + back_to_all_guides: Back to all guides + related_guides: Related Guides + footer: + contribute: + heading: Contribute + description: Want to make a suggestion? This content is open source. Help us improve it. + button: Contribute + subscribe: + heading: Stay in touch + description: Be the first to hear about GitHub's latest open source tips and resources. + label: Email Address + button: Subscribe + byline: + # [code], [love], and [github] will be replaced by octicons + format: "[code] with [love] by [github] and [friends]" + # Label for code octicon + code_label: code + # Label for love octicon + love_label: love + # Label for the contributors link + friends_label: friends diff --git a/_includes/footer.html b/_includes/footer.html index 8c95fa5f978..2e6525b49e9 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -1,3 +1,4 @@ +{% assign t = site.data.locales[page.lang][page.lang] %} diff --git a/_includes/head.html b/_includes/head.html index c574f7515f8..464782a67e4 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -5,4 +5,18 @@ {% seo %} + {% if page.lang and site.data.locales.size > 1 %} + {% assign locales = site.data.locales | sort %} + {% for locale in locales %} + {% assign lang = locale[0] %} + {% assign page_lang_slash = page.lang | append: '/' | prepend: '/' %} + {% assign default_url = page.url | replace: page_lang_slash, '/' %} + {% if lang == "en" %} + + + {% else %} + + {% endif %} + {% endfor %} + {% endif %} diff --git a/_includes/nav.html b/_includes/nav.html index 8421741ecaa..2f128f3fc89 100644 --- a/_includes/nav.html +++ b/_includes/nav.html @@ -1,20 +1,21 @@ +{% assign t = site.data.locales[page.lang][page.lang] %}