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

repo sync #606

Merged
merged 5 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/crowdin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Please ping @github/docs-localization in the PR whenever you update this file!

name: Crowdin Sync

on:
Expand All @@ -25,18 +23,20 @@ jobs:

# Using a custom config temporarily to avoid clobbering the existing crowdin.yml
# that is used by the github-help-docs OAuth integration.
config: 'crowdin-actions-config.yml'
config: 'crowdin.yml'

# This is the name of the git branch that Crowdin will create when opening a pull request.
# This branch does NOT need to be manually created. It will be created automatically by the action.
localization_branch_name: automated-crowdin-translations
localization_branch_name: translations

# This is the name of the top-level directory that Crowdin will use for files.
# Note that this is not a "branch" in the git sense, but more like a top-level directory in your Crowdin project.
# This branch does NOT need to be manually created. It will be created automatically by the action.
crowdin_branch_name: crowdin-main
crowdin_branch_name: main

env:
# Using an @octoglot token instead of the default Actions-provided GITHUB_TOKEN here
# so that subsequent workflows will be able to run on the pull request created by this workflow.
GITHUB_TOKEN: ${{ secrets.OCTOGLOT_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}

# This is a numeric id, not to be confused with Crowdin API v1 "project identifier" string
Expand Down
25 changes: 0 additions & 25 deletions crowdin-actions-config.yml

This file was deleted.

7 changes: 7 additions & 0 deletions crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ files:
"data/graphql",
"data/products.yml"
]

# These end up as env vars used by the GitHub Actions workflow
project_id_env: CROWDIN_PROJECT_ID
api_token_env: CROWDIN_PERSONAL_TOKEN

# https://support.crowdin.com/configuration-file-v3/#saving-directory-structure-on-server
preserve_hierarchy: true
44 changes: 32 additions & 12 deletions script/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ Runs tests. Equivalent of `npm test`.

## Additional scripts

### [`anonymize-branch.js`](anonymize-branch.js)

Flatten all the commits in the current branch into a single anonymized @Octomerger commit

Usage: script/anonymize-branch.js <new-commit-message> [base-branch] Example: script/anonymize-branch.js "nothing to see here" If the optional [base-branch] argument is omitted, it will default to `main`

---


### [`archive-enterprise-version.js`](archive-enterprise-version.js)

Run this script during the Enterprise deprecation process to download static copies of all pages for the oldest supported Enterprise version. See the Enterprise deprecation issue template for instructions.
Expand Down Expand Up @@ -270,6 +279,19 @@ Usage $ script/new-versioning/main
---


### [`new-versioning/update-not-fpt-conditionals.js`](new-versioning/update-not-fpt-conditionals.js)

Run this script to update these Liquid conditionals:

{% if currentVersion != 'free-pro-team@latest' %}

to:

{% if enterpriseServerVersions contains currentVersion %}

---


### [`new-versioning/update-products-yml.js`](new-versioning/update-products-yml.js)


Expand Down Expand Up @@ -307,15 +329,7 @@ This script is run as a git precommit hook (installed by husky after npm install

### [`preview-openapi-changes`](preview-openapi-changes)

This script stitches and unstitches the `github/github` OpenAPI description via `rest-api-operations` to produce a local preview in docs-internal.

`github`, `rest-api-operations`, and `docs-internal` must share a parent directory locally.

You must bootstrap `github` for this script to work. To check if you need to bootstrap, check if the `bin` directory in `github` exists locally. If it does not exist, run `./script/bootstrap` from the `github` directory.

To stitch the repos together and do an npm build, pass the `stitch` argument.

To unstitch the repos and revert them to their pre-stitched state, pass the `unstitch` argument.

---

Expand Down Expand Up @@ -379,13 +393,19 @@ Run this script to remove reusables and image files that exist in the repo but a

This is a convenience script for replacing the contents of translated files with the English content from their corresponding source file.

It's intended to be a workaround to temporarily bypass Crowdin parser bugs while we wait for Crowdin to fix them.
It's intended to be a workaround to temporarily bypass Crowdin parser bugs while we wait for translators to fix them.

Usage: script/reset-translated-file.js <filename>

Examples:

reset a single translated file using a relative path: $ script/reset-translated-file.js translations/es-XL/content/actions/index.md

Usage: script/reset-translated-File.js <relative-filename> [<two-letter-language-code>]
reset a single translated file using a full path: $ script/reset-translated-file.js /Users/z/git/github/docs-internal/translations/es-XL/content/actions/index.md

script/reset-translated-File.js content/desktop/foo.md -> resets all translations of foo.md
reset all language variants of a single English file (using a relative path): $ script/reset-translated-file.js content/actions/index.md $ script/reset-translated-file.js data/ui.yml

script/reset-translated-File.js content/desktop/foo.md de -> resets german translation of foo.md
reset all language variants of a single English file (using a full path): $ script/reset-translated-file.js /Users/z/git/github/docs-internal/content/desktop/index.md $ script/reset-translated-file.js /Users/z/git/github/docs-internal/data/ui.yml

---

Expand Down
37 changes: 29 additions & 8 deletions script/reset-translated-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,26 @@
// files with the English content from their corresponding source file.
//
// It's intended to be a workaround to temporarily bypass Crowdin parser bugs
// while we wait for Crowdin to fix them.
// while we wait for translators to fix them.
//
// Usage:
// script/reset-translated-File.js <relative-filename> [<two-letter-language-code>]
// script/reset-translated-file.js <filename>
//
// script/reset-translated-File.js content/desktop/foo.md
// -> resets all translations of foo.md
// Examples:
//
// script/reset-translated-File.js content/desktop/foo.md de
// -> resets german translation of foo.md
// reset a single translated file using a relative path:
// $ script/reset-translated-file.js translations/es-XL/content/actions/index.md
//
// reset a single translated file using a full path:
// $ script/reset-translated-file.js /Users/z/git/github/docs-internal/translations/es-XL/content/actions/index.md
//
// reset all language variants of a single English file (using a relative path):
// $ script/reset-translated-file.js content/actions/index.md
// $ script/reset-translated-file.js data/ui.yml
//
// reset all language variants of a single English file (using a full path):
// $ script/reset-translated-file.js /Users/z/git/github/docs-internal/content/desktop/index.md
// $ script/reset-translated-file.js /Users/z/git/github/docs-internal/data/ui.yml
//
// [end-readme]

Expand All @@ -25,8 +34,20 @@ const fs = require('fs')
const path = require('path')
const languages = require('../lib/languages')

const [relativePath, languageCode] = process.argv.slice(2)
assert(relativePath, 'first arg must be a target filename')
const [pathArg] = process.argv.slice(2)
assert(pathArg, 'first arg must be a target filename')
let languageCode

// Is the arg a fully-qualified path?
let relativePath = fs.existsSync(pathArg)
? path.relative(process.cwd(), pathArg)
: pathArg

// extract relative path and language code if pathArg is in the format `translations/<lang>/path/to/file`
if (relativePath.startsWith('translations/')) {
languageCode = Object.values(languages).find(language => relativePath.startsWith(language.dir) && language.code !== 'en').code
relativePath = relativePath.split(path.sep).slice(2).join(path.sep)
}

const englishFile = path.join(process.cwd(), relativePath)
assert(fs.existsSync(englishFile), `file does not exist: ${englishFile}`)
Expand Down