Skip to content

Commit 2630dde

Browse files
authored
Merge pull request #157 from vuejs-id/master
[pull] indonesian from master
2 parents fda75d7 + 8188362 commit 2630dde

File tree

5 files changed

+275
-9
lines changed

5 files changed

+275
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export const labels = {
2+
language: 'Language',
3+
github: 'GitHub',
4+
lastCommit: 'Last commit',
5+
last90Days: 'Last 90 days',
6+
loadDetails: 'Load Details',
7+
commits: 'commits',
8+
loading: 'Loading...'
9+
}
10+
11+
// Repos are in alphabetical order by the language code
12+
// You may need to clear your sessionStorage when adding a new item to this list
13+
export const repos = [
14+
{ lang: 'en-us', owner: 'vuejs', repo: 'docs-next', branch: 'master', url: 'https://v3.vuejs.org/' },
15+
{ lang: 'id', owner: 'vuejs-id', repo: 'docs-next', branch: 'indonesian' },
16+
{ lang: 'ja', owner: 'vuejs-jp', repo: 'ja.vuejs.org', branch: 'lang-ja', url: 'https://v3.ja.vuejs.org/' },
17+
{ lang: 'ko', owner: 'vuejs-kr', repo: 'docs-next', branch: 'rootKoKr', url: 'https://v3.ko.vuejs.org/' },
18+
{ lang: 'pt-br', owner: 'vuejs-br', repo: 'docs-next', branch: 'master', url: 'https://vuejsbr-docs-next.netlify.app/' },
19+
{ lang: 'ru', owner: 'translation-gang', repo: 'docs-next', branch: 'master' },
20+
{ lang: 'zh-cn', owner: 'vuejs', repo: 'docs-next-zh-cn', branch: 'master', url: 'https://v3.cn.vuejs.org/' }
21+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
<template>
2+
<table>
3+
<thead>
4+
<tr>
5+
<th>{{ labels.language }}</th>
6+
<th>{{ labels.github }}</th>
7+
<th>{{ labels.lastCommit }}</th>
8+
<th>{{ labels.last90Days }}</th>
9+
</tr>
10+
</thead>
11+
<tbody>
12+
<tr v-for="({ lang, owner, repo, url, count, date }, index) in merged">
13+
<td>
14+
<a v-if="url" :href="url" target="_blank">
15+
{{ lang }} <OutboundLink />
16+
</a>
17+
<template v-else>
18+
{{ lang }}
19+
</template>
20+
</td>
21+
<td>
22+
<a :href="`https://github.com/${owner}/${repo}/`" target="_blank">{{ owner }}/{{ repo }} <OutboundLink /></a>
23+
</td>
24+
<template v-if="showLoadButton">
25+
<td v-if="index === 0" colspan="2" :rowspan="merged.length" class="load-cell">
26+
<button @click="load">{{ labels.loadDetails }}</button>
27+
</td>
28+
</template>
29+
<template v-else>
30+
<td>{{ date }}</td>
31+
<td>
32+
{{ count }}{{ count === 100 ? '+' : '' }}
33+
<template v-if="typeof count === 'number'">
34+
{{ labels.commits }}
35+
</template>
36+
</td>
37+
</template>
38+
</tr>
39+
</tbody>
40+
</table>
41+
</template>
42+
43+
<script>
44+
import { labels, repos } from './translations-data.js'
45+
46+
const getLastDate = async ({ owner, repo, branch }) => {
47+
const response = await fetch(`https://api.github.com/repos/${owner}/${repo}/branches/${branch}`)
48+
49+
const data = await response.json()
50+
51+
const dateTime = data.commit.commit.committer.date
52+
53+
return dateTime.split('T')[0]
54+
}
55+
56+
const DATE_90_DAYS_AGO = new Date(Date.now() - 90 * 24 * 60 * 60 * 1000).toJSON().replace(/\.\d*/, '')
57+
58+
const commitCount = async ({ owner, repo }) => {
59+
const response = await fetch(`https://api.github.com/repos/${owner}/${repo}/commits?since=${DATE_90_DAYS_AGO}&per_page=100`)
60+
61+
const data = await response.json()
62+
63+
return data.length
64+
}
65+
66+
export default {
67+
name: 'translations',
68+
69+
data () {
70+
const dates = {}
71+
72+
for (const { lang } of repos) {
73+
dates[lang] = null
74+
}
75+
76+
return {
77+
showLoadButton: true,
78+
dates,
79+
counts: { ...dates },
80+
labels,
81+
repos
82+
}
83+
},
84+
85+
computed: {
86+
merged () {
87+
return this.repos.map(repo => ({
88+
...repo,
89+
date: this.dates[repo.lang],
90+
count: this.counts[repo.lang]
91+
}))
92+
}
93+
},
94+
95+
mounted () {
96+
let stats = null
97+
98+
try {
99+
stats = JSON.parse(sessionStorage.getItem('translation-stats'))
100+
} catch {
101+
}
102+
103+
if (!stats) {
104+
return
105+
}
106+
107+
const { date, counts, dates } = stats
108+
109+
if (!date || date + 3 * 60 * 60 * 1000 < Date.now()) {
110+
return
111+
}
112+
113+
this.dates = dates
114+
this.counts = counts
115+
this.showLoadButton = false
116+
},
117+
118+
methods: {
119+
async load () {
120+
this.showLoadButton = false
121+
122+
await Promise.all(this.repos.map(this.loadRepo))
123+
124+
this.saveStats()
125+
},
126+
127+
async loadRepo (repo) {
128+
await this.loadLastCommit(repo)
129+
130+
return this.loadCommitCount(repo)
131+
},
132+
133+
async loadLastCommit (repo) {
134+
const { lang } = repo
135+
136+
this.dates[lang] = labels.loading
137+
138+
let date = '-'
139+
140+
try {
141+
date = await getLastDate(repo)
142+
} catch {
143+
}
144+
145+
this.dates[lang] = date
146+
},
147+
148+
async loadCommitCount (repo) {
149+
const { lang } = repo
150+
151+
const date = this.dates[lang]
152+
let count = 0
153+
154+
if (date === '-') {
155+
count = '-'
156+
} else if (date > DATE_90_DAYS_AGO) {
157+
this.counts[lang] = labels.loading
158+
159+
try {
160+
count = await commitCount(repo)
161+
} catch {
162+
count = '-'
163+
}
164+
}
165+
166+
this.counts[lang] = count
167+
},
168+
169+
saveStats () {
170+
const data = {
171+
date: Date.now(),
172+
counts: this.counts,
173+
dates: this.dates
174+
}
175+
176+
// GitHub limits request rates, so we store the stats in sessionStorage
177+
sessionStorage.setItem('translation-stats', JSON.stringify(data))
178+
}
179+
}
180+
}
181+
</script>
182+
183+
<style lang="scss" scoped>
184+
@import "@theme/styles/_settings.scss";
185+
186+
.load-cell {
187+
background: #f6f8fa;
188+
text-align: center;
189+
190+
button {
191+
padding: 4px 20px;
192+
height: 50px;
193+
border-radius: 9999px;
194+
font-size: 1.05em;
195+
font-weight: 600;
196+
letter-spacing: 0.1em;
197+
min-width: 8em;
198+
color: #fff;
199+
background-color: $green;
200+
box-sizing: border-box;
201+
border: 1px solid currentColor;
202+
appearance: none;
203+
cursor: pointer;
204+
}
205+
}
206+
</style>

src/.vuepress/config.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,15 @@ module.exports = {
410410
text: 'Terjemahan',
411411
link: '#',
412412
items: [
413+
// Translation maintainers: Please include the link below to the English documentation
414+
// {
415+
// text: 'English',
416+
// link: 'https://v3.vuejs.org/'
417+
// },
418+
{
419+
text: '中文',
420+
link: 'https://v3.cn.vuejs.org/'
421+
},
413422
{
414423
text: 'Bahasa Inggris',
415424
link: 'https://v3.vuejs.org/'
@@ -419,8 +428,8 @@ module.exports = {
419428
link: 'https://v3.ko.vuejs.org/'
420429
},
421430
{
422-
text: '中文',
423-
link: 'https://v3.cn.vuejs.org/'
431+
text: 'More Translations',
432+
link: '/guide/contributing/translations#community-translations'
424433
}
425434
]
426435
}

src/community/join.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ Apart from answering questions and sharing resources in the forum and chat, ther
4545

4646
### Translate Docs
4747

48-
Vue has already spread across the globe, with even the core team in at least half a dozen timezones. [The forum](https://forum.vuejs.org/) includes 7 languages and counting and many of our docs have [actively-maintained translations](https://github.com/vuejs?utf8=%E2%9C%93&q=vuejs.org). We're very proud of Vue's international reach, but we can do even better.
49-
5048
I hope that right now, you're reading this sentence in your preferred language. If not, would you like to help us get there?
5149

52-
If so, please feel free to fork the repo for [these docs](https://github.com/vuejs/vuejs.org/) or for any other officially maintained documentation, then start translating. Once you've made some progress, open an issue or pull request in the main repo and we'll put out a call for more contributors to help you out.
50+
See the [Translations guide](/guide/contributing/translations.html) for more details on how you can get involved.
5351

5452
### Become a Community Leader
5553

+36-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,43 @@
11
# Translations
22

3-
Vue has spread across the globe, with the core team being in at least half a dozen different timezones. [The forum](https://forum.vuejs.org/) includes 7 languages and counting and many of our docs have [actively-maintained translations](https://github.com/vuejs?utf8=%E2%9C%93&q=vuejs.org). We're very proud of Vue's international reach, but we can do even better.
3+
Vue has spread across the globe, with the core team being in at least half a dozen different timezones. The community is growing all the time and we want to make the documentation accessible to as many people as possible.
44

5-
## Can we start translating Vue 3 docs?
5+
Providing translations for the documentation is not something that the core team can manage alone. Thankfully, we have a great community of translators making contributions both large and small. If you've been thinking about contributing to the project, perhaps this is a good place to start?
66

7-
Yes! We are ready for translation!
7+
## Community translations
8+
9+
The table below lists GitHub repositories for community translations. These are translations made by the community, for the community. Some of these translations may be incomplete but they can still make the Vue experience significantly more enjoyable for readers who prefer these languages.
10+
11+
For completeness, we've also included the official documentation in the list.
12+
13+
<guide-contributing-translations />
14+
15+
Thank you to everyone who has contributed to these translations. Your hard work is very much appreciated.
816

917
## How can I get involved with translations?
1018

11-
The best way to get started is to check out [this pinned issue](https://github.com/vuejs/docs-next/issues/478) that contains active discussions on the various initiatives happening in the community.
19+
The first step is to check whether there is an existing translation for the relevant language. In addition to the table above, a good place to start is [this pinned issue](https://github.com/vuejs/docs-next/issues/478), which is used to keep track of the various translation initiatives happening in the community.
20+
21+
If there's already an active translation then there are various ways you can help out. The GitHub repository should be a good place to start gathering information about how a particular translation is managed and who does what. All translation repositories should allow you to file issues and open Pull Requests if you have suggestions for improving the translation.
22+
23+
## What if there isn't an existing translation?
24+
25+
If you want to start a new translation then please do. You don't need our permission to start but you should read the rest of this page carefully to make sure you're clear about what's involved.
26+
27+
Before you start, you might want to check whether there was a community translation for Vue 2. [This pinned issue](https://github.com/vuejs/vuejs.org/issues/2015) from the Vue 2 documentation may help.
28+
29+
Working on a translation is more fun, and more likely to succeed, if there are multiple contributors. Even if you don't know anyone personally who can help out you may be able to find other translators from within the Vue community.
30+
31+
The documentation is constantly being updated. Many changes are small and don't directly impact the translations but others make important improvements that also need translating. Before you start work on a new translation you may want to take a look at the GitHub repositories for some other languages to get a sense of how they handle the update process.
32+
33+
When you first start a translation, you may want to use a personal GitHub repository. That's fine, so long as it's publicly accessible and open to contributions from others. Make sure the *Issues* tab is enabled in the repository's settings. You can migrate the repository to a shared organization at a later stage.
34+
35+
Once you start a translation, be sure to add it to [the pinned issue](https://github.com/vuejs/docs-next/issues/478) so that the rest of the community can find it.
36+
37+
We also encourage you to update the root-level `README.md` at an early stage. Most translations add extra information to help potential contributors get involved.
38+
39+
## Can I add my translation to this page?
40+
41+
If you've translated more than half of the documentation then please open a Pull Request to add your repository to the table of community translations on this page.
42+
43+
The official documentation is deployed on [Netlify](https://url.netlify.com/HJ8X2mxP8). We encourage you to do the same. Some community translators use their own Netlify accounts but we're happy to host community translations on our account once they're at an advanced stage.

0 commit comments

Comments
 (0)