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

Sync with reactjs.org @ bab2a349 #128

Merged
merged 10 commits into from
Feb 25, 2019
3 changes: 3 additions & 0 deletions content/authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ sophiebits:
steveluscher:
name: Steven Luscher
url: https://twitter.com/steveluscher
tesseralis:
name: Nat Alison
url: https://twitter.com/tesseralis
timer:
name: Joe Haddad
url: https://twitter.com/timer150
Expand Down
76 changes: 76 additions & 0 deletions content/blog/2019-02-23-is-react-translated-yet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: "Is React Translated Yet? ¡Sí! Sim! はい!"
author: [tesseralis]
---

We’re excited to announce an ongoing effort to maintain official translations of the React documentation website into different languages. Thanks to the dedicated efforts of React community members from around the world, React is now being translated into *over 30* languages! You can find them on the new [Languages](/languages) page.

In addition, the following three languages have completed translating most of the React Docs! 🎉

* **Spanish: [es.reactjs.org](https://es.reactjs.org)**
* **Japanese: [ja.reactjs.org](https://ja.reactjs.org)**
* **Brazilian Portuguese: [pt-br.reactjs.org](https://pt-br.reactjs.org)**

Special congratulations to [Alejandro Ñáñez Ortiz](https://github.com/alejandronanez), [Rainer Martínez Fraga](https://github.com/carburo), [David Morales](https://github.com/dmorales), [Miguel Alejandro Bolivar Portilla](https://github.com/Darking360), and all the contributors to the Spanish translation for being the first to *completely* translate the core pages of the docs!

## Why Localization Matters

React already has many meetups and conferences around the world, but many programmers don't use English as their primary language. We’d love to support local communities who use React by making our documentation available in most popular languages.

In the past, React community members have created unofficial translations for [Chinese](https://github.com/discountry/react), [Arabic](https://wiki.hsoub.com/React), and [Korean](https://github.com/reactjs/ko.reactjs.org/issues/4); by making an official channel for these translated docs we're hoping to make them easier to find and help make sure that non-English-speaking users of React aren't left behind.

## Contributing

If you would like to help out on a current translation, check out the [Languages](/languages) page and click on the "Contribute" link for your language.

Can't find your language? If you'd like to maintain your langauge's translation fork, follow the instructions in the [translation repo](https://github.com/reactjs/reactjs.org-translation#starting-a-new-translation)!

## Backstory

Hi everyone! I'm [Nat](https://twitter.com/tesseralis)! You may know me as the [polyhedra lady](https://www.youtube.com/watch?v=Ew-UzGC8RqQ). For the past few weeks, I've been helping the React team coordinate their translation effort. Here's how I did it.

Our original approach for translations was to use a SaaS platform that allows users to submit translations. There was already a [pull request](https://github.com/reactjs/reactjs.org/pull/873) to integrate it and my original responsibility was to finish that integration. However, we had concerns about the feasibility of that integration and the current quality of translations on the platform. Our primary concern was ensuring that translations kept up to date with the main repo and didn't become "stale".

[Dan](https://twitter.com/dan_abramov) encouraged me to look for alternate solutions, and we stumbled across how [Vue](https://vuejs.org) maintained its translations -- through different forks of the main repo on GitHub. In particular, the [Japanese translation](https://jp.vuejs.org) used a bot to periodically check for changes in the English repo and submits pull requests whenever there is a change.

This approach appealed to us for several reasons:

* It was less code integration to get off the ground.
* It encouraged active maintainers for each repo to ensure quality.
* Contributors already understand GitHub as a platform and are motivated to contribute directly to the React organization.

We started of with an initial trial period of three languages: Spanish, Japanese, and Simplified Chinese. This allowed us to work out any kinks in our process and make sure future translations are set up for success. I wanted to give the translation teams freedom to choose whatever tools they felt comfortable with. The only requirement is a [checklist](https://github.com/reactjs/reactjs.org-translation/blob/master/PROGRESS.template.md) that outlines the order of importance for translating pages.

After the trial period, we were ready to accept more languages. I created [a script](https://github.com/reactjs/reactjs.org-translation/blob/master/scripts/create.js) to automate the creation of the new language repo, and a site, [Is React Translated Yet?](https://isreacttranslatedyet.com), to track progress on the different translations. We started *10* new translations on our first day alone!

Because of the automation, the rest of the maintance went mostly smoothly. We eventually created a [Slack channel](https://rt-slack-invite.herokuapp.com) to make it easier for translators to share information, and I released a guide solidifying the [responsibilities of maintainers](https://github.com/reactjs/reactjs.org-translation/blob/master/maintainer-guide.md). Allowing translators to talk with each other was a great boon -- for example, the Arabic, Persian, and Hebrew translations were able to talk to each other in order to get [right-to-left text](https://en.wikipedia.org/wiki/Right-to-left) working!

## The Bot

The most challenging part was getting the bot to sync changes from the English version of the site. Initially we were using the [che-tsumi](https://github.com/vuejs-jp/che-tsumi) bot created by the Japanese Vue translation team, but we soon decided to build our own bot to suit our needs. In particular, the che-tsumi bot works by [cherry picking](https://git-scm.com/docs/git-cherry-pick) new commits. This ended up causing a cavalade of new issues that were interconnected, especially when [Hooks were released](/blog/2019/02/06/react-v16.8.0.html).

In the end, we decided that instead of cherry picking each commit, it made more sense to merge all new commits and create a pull request around once a day. Conflicts are merged as-is and listed in the [pull request](https://github.com/reactjs/pt-BR.reactjs.org/pull/114), leaving a checklist for maintainers to fix.

Creating the [sync script](https://github.com/reactjs/reactjs.org-translation/blob/master/scripts/sync.js) was easy enough: it downloads the translated repo, adds the original as a remote, pulls from it, merges the conflicts, and creates a pull request.

The problem was finding a place for the bot to run. I'm a frontend developer for a reason -- Heroku and its ilk are alien to me and *endlessly* frustrating. In fact, until this past Tuesday, I was running the script by hand on my local machine!

The biggest challenge was space. Each fork of the repo is around 100MB -- which takes minutes to clone on my local machine. We have *32* forks, and the free tiers or most deployment platforms I checked limited you to 512MB of storage.

After lots of notepad calculations, I found a solution: delete each repo once we've finished the script and limit the concurrency of `sync` scripts that run at once to be within the storage requirements. Luckily, Heroku dynos have a much faster Internet connection and are able to clone even the React repo quickly.

There were other smaller issues that I ran into. I tried using the [Heroku Scheduler](https://elements.heroku.com/addons/scheduler) add-on so I didn't have to write any actual `watch` code, but it end up running too inconsistently, and I [had an existential meltdown on Twitter](https://twitter.com/tesseralis/status/1097387938088796160) when I couldn't figure out how to send commits from the Heroku dyno. But in the end, this frontend engineer was able to get the bot working!

There are, as always, improvements I want to make to the bot. Right now it doesn't check whether there is an outstanding pull request before pushing another one. It's still hard to tell the exact change that happened in the original source, and it's possible to miss out on a needed translation change. But I trust the maintainers we've chosen to work through these issues, and the bot is [open source](https://github.com/reactjs/reactjs.org-translation) if anyone wants to help me make these improvements!

## Thanks

Finally, I would like to extend my gratitude to the following people and groups:

* All the translation maintainers and contributors who are helping translate React to more than thirty languages.
* The [Vue.js Japan User Group](https://github.com/vuejs-jp) for initiating the idea of having bot-managed translations, and especially [Hanatani Takuma](https://github.com/potato4d) for helping us understand their approach and helping maintain the Japanese translation.
* [Soichiro Miki](https://github.com/smikitki) for many [contributions](https://github.com/reactjs/reactjs.org/pull/1636) and thoughtful comments on the overall translation process, as well as for maintaining the Japanese translation.
* [Eric Nakagawa](https://github.com/ericnakagawa) for managing our previous translation process.
* [Brian Vaughn](https://github.com/bvaughn) for setting up the [languages page](/languages) and managing all the subdomains.

And finally, thank you to [Dan Abramov](https://twitter.com/dan_abramov) for giving me this opportunity and being a great mentor along the way.
2 changes: 1 addition & 1 deletion content/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ React has been designed from the start for gradual adoption, and **you can use a

### Online Playgrounds {#online-playgrounds}

If you're interested in playing around with React, you can use an online code playground. Try a Hello World template on [CodePen](codepen://hello-world) or [CodeSandbox](https://codesandbox.io/s/new).
If you're interested in playing around with React, you can use an online code playground. Try a Hello World template on [CodePen](codepen://hello-world), [CodeSandbox](https://codesandbox.io/s/new), or [Glitch](https://glitch.com/edit/#!/remix/starter-react-template).

If you prefer to use your own text editor, you can also [download this HTML file](https://raw.githubusercontent.com/reactjs/reactjs.org/master/static/html/single-file-example.html), edit it, and open it from the local filesystem in your browser. It does a slow runtime code transformation, so we'd only recommend using this for simple demos.

Expand Down
2 changes: 1 addition & 1 deletion content/docs/hooks-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ There are a few more heuristics, and they might change over time as we fine-tune

### How do lifecycle methods correspond to Hooks? {#how-do-lifecycle-methods-correspond-to-hooks}

* `constructor`: Function components don't need a constructor. You can initialize the state in the [`useState`](/docs/hooks-reference.html#usestate) call. If computing is expensive, you can pass a function to `useState`.
* `constructor`: Function components don't need a constructor. You can initialize the state in the [`useState`](/docs/hooks-reference.html#usestate) call. If computing the initial state is expensive, you can pass a function to `useState`.

* `getDerivedStateFromProps`: Schedule an update [while rendering](#how-do-i-implement-getderivedstatefromprops) instead.

Expand Down
133 changes: 133 additions & 0 deletions content/languages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Status enums indicate what percentage of "core" content has been translated:
# 0: Incomplete (0–49%)
# 1: Partially complete (50–94%)
# 2: Complete (95–100%)

- name: English
translated_name: English
code: en
status: 2
- name: Arabic
translated_name: العربية
code: ar
status: 0
- name: Azerbaijani
translated_name: Azərbaycanca
code: az
status: 0
- name: Bulgarian
translated_name: Български
code: bg
status: 0
- name: Bengali
translated_name: বাংলা
code: bn
status: 0
- name: German
translated_name: Deutsch
code: de
status: 0
- name: Spanish
translated_name: Español
code: es
status: 2
- name: Persian
translated_name: فارسی
code: fa
status: 0
- name: French
translated_name: Français
code: fr
status: 0
- name: Hebrew
translated_name: עברית
code: he
status: 0
- name: Hindi
translated_name: हिन्दी
code: hi
status: 0
- name: Armenian
translated_name: Հայերեն
code: hy
status: 0
- name: Indonesian
translated_name: Bahasa Indonesia
code: id
status: 0
- name: Italian
translated_name: Italiano
code: it
status: 0
- name: Japanese
translated_name: 日本語
code: ja
status: 1
- name: Korean
translated_name: 한국어
code: ko
status: 0
- name: Malayalam
translated_name: മലയാളം
code: ml
status: 0
- name: Nepali
translated_name: नेपाली
code: ne
status: 0
- name: Dutch
translated_name: Nederlands
code: nl
status: 0
- name: Polish
translated_name: Polski
code: pl
status: 0
- name: Portuguese (Brazil)
translated_name: Português do Brasil
code: pt-br
status: 1
- name: Portuguese (Portugal)
translated_name: Português europeu
code: pt-pt
status: 0
- name: Romanian
translated_name: Română
code: ro
status: 0
- name: Russian
translated_name: Русский
code: ru
status: 0
- name: Sinhala
translated_name: සිංහල
code: si
status: 0
- name: Tamil
translated_name: தமிழ்
code: ta
status: 0
- name: Turkish
translated_name: Türkçe
code: tr
status: 0
- name: Ukrainian
translated_name: Українська
code: uk
status: 0
- name: Uzbek
translated_name: Oʻzbekcha
code: uz
status: 0
- name: Vietnamese
translated_name: Tiếng Việt
code: vi
status: 0
- name: Simplified Chinese
translated_name: 简体中文
code: zh-hans
status: 0
- name: Traditional Chinese
translated_name: 繁體中文
code: zh-hant
status: 0
35 changes: 14 additions & 21 deletions src/components/LayoutHeader/DocSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,25 @@ class DocSearch extends Component<{}, State> {
flex: '0 0 auto',
flexDirection: 'row',
alignItems: 'center',
paddingLeft: '0.5rem',
paddingRight: '0.5rem',
paddingLeft: '0.25rem',
paddingRight: '0.25rem',

[media.lessThan('small')]: {
[media.lessThan('expandedSearch')]: {
justifyContent: 'flex-end',
},
[media.lessThan('large')]: {
marginRight: 10,
},
[media.between('small', 'medium')]: {
width: 'calc(100% / 3)',
},
[media.between('medium', 'xlarge')]: {
width: 'calc(100% / 6)',
},
[media.greaterThan('small')]: {
minWidth: 120,
// TODO: Something like this could show the full search box in more cases
// but it currently breaks its expanding animation.
// [media.between('mediumSearch', 'largerSearch')]: {
// width: 'calc(100% / 8)',
// },
[media.greaterThan('expandedSearch')]: {
minWidth: 100,
},
}}>
<input
css={{
width: '100%',
appearance: 'none',
background: 'transparent',
border: 0,
Expand All @@ -71,26 +69,21 @@ class DocSearch extends Component<{}, State> {
fontWeight: 300,
fontFamily: 'inherit',
position: 'relative',
padding: '5px 5px 5px 29px',
padding: '4px 4px 4px 29px',
backgroundImage: 'url(/search.svg)',
backgroundSize: '16px 16px',
backgroundRepeat: 'no-repeat',
backgroundPositionY: 'center',
backgroundPositionX: '5px',
backgroundPositionX: '4px',

':focus': {
outline: 0,
backgroundColor: colors.lighter,
borderRadius: '0.25rem',
},

[media.lessThan('large')]: {
[media.lessThan('expandedSearch')]: {
fontSize: 16,
},
[media.greaterThan('small')]: {
width: '100%',
},
[media.lessThan('small')]: {
width: '16px',
transition: 'width 0.2s ease, padding 0.2s ease',
paddingLeft: '16px',
Expand Down
Loading