Skip to content

Commit

Permalink
i18n Crowdin integration (#880) (#881)
Browse files Browse the repository at this point in the history
* i18n Crowdin integration (#880)

* feat: add crowdin integration with github actions

* feat: add platforms

* feat: add extra ignored file paths and update crowdin copy script

* feat: edit file to triger upload

* feat: doc change

* feat: new

* udpate copy

* feat: add download worflow

* feat: update git ignore

* update

* update

* update

* New Crowdin translations by GitHub Action

* remove copy file from workflow

* New Crowdin translations by GitHub Action

* Update README.mdx

* New Crowdin translations by GitHub Action

* feat: add copy workflow

* update node version

* chore: Copy ignored files using crowdin:copy

* udpate copy

* udpate copy

* Update cb-retrieve-related-operations.api.mdx

* update copy

* Update cb-retrieve-related-operations.api.mdx

* update copy

* update copy

* update copy

* update copy

* Update get-all-offers.api.mdx

* chore: Copy ignored files using crowdin:copy

* test upload

* update links

* update link

* update link

* update link

* clean i18n

* clean i18n

* clean i18n

* clean i18n

* clean i18n

* clean i18n

* clean i18n

* clean up

---------

Co-authored-by: Lucas Gil-Arranz <[email protected]>
Co-authored-by: Crowdin Bot <[email protected]>
Co-authored-by: github-actions <[email protected]>
Co-authored-by: Elliot Voris <[email protected]>

* provide translation spots for custom react components

* update crowdin cli, modify/customize scripts

* config updates and changes

* modify version dropdown to display on localized URLs too

* simple perl commands to fix some of the markdown parsing problems

* modify some URLs (silly markdown parsing stuff again)

* fixup markdown formatting

* test only the english version in github

* make the copy action workflow run on-demand, fix npm script name

* gitignore the translation directory

* remove example env file

* add note about build command in dockerfile

* pass crowdin token from makefile to dockerfile

* add dot-slash to links in AP RPC methods table

* use localization-aware edit URLs for docs

* update build and test workflow actions versions

* update docker and makefile config to pass token more securely

* Revert "update docker and makefile config to pass token more securely"

This reverts commit fdefef7.

* explicitly specify broken anchors behavior

* sync both ways in Dockerfile build

* put some problematic hubble data field notes into code tags

* include meeting notes pages in mdx formatting

* delete package-lock.json file

* trigger a new container build

* trigger a new container build

* make crowdin upload workflow only on-demand

* remove IDs from docs frontmatter

* trigger a new container build

* fix some broken links from renaming SDP files

* add the announcement bar to translated pages

* remove unnecessary console log

* build spanish only for now

* trigger a new container build

* trigger a new container build

* add a test file

* remove test file

* modify crowdin upload/download commands

* write explicit heading ids for markdown docs

* Revert "write explicit heading ids for markdown docs"

This reverts commit 5b420a1.

* fix some broken links

* warn instead of log broken links

* fix some poorly formed links in sdp docs

* add another crowdin fix to the script

* upgrade crowdin cli to v4.5.0

* fix markdown formatting on ap rpc methods page

* fix some broken ap links

* fix some broken links in one of the guides

* translate wayfinding box titles

* remove dapps-challenge translations fixes, rename script file

* fix more broken links

* yet another batch of link fixing

* more broken links

* remove unused link definition

* build for english and spanish locales

* make build fail on broken link

* fix a couple wrong anchor links (in english)

* more properly display related guides in how-to guides pages

* display platforms and data sidebars better in spanish

* build: only build translations in production (set via docker arg)

---------

Co-authored-by: lucasgil-arranz <[email protected]>
Co-authored-by: Lucas Gil-Arranz <[email protected]>
  • Loading branch information
3 people authored Dec 18, 2024
1 parent 230e45a commit 029ed2e
Show file tree
Hide file tree
Showing 119 changed files with 1,416 additions and 699 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/copy-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Crowdin Copy and Create PR

on:
workflow_dispatch:
# push:
# paths: [ 'docs/**', 'platforms/**','i18n/en/**', 'src/pages/**', 'meeting-notes/**' ]
# branches: [ main ]

permissions:
contents: write
pull-requests: write

jobs:
crowdin_copy_and_pr:
runs-on: ubuntu-latest

steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main

- name: Merge latest changes from origin/main
run: |
git fetch origin
git checkout main
git merge origin/main
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: yarn install

- name: Run crowdin:fix
run: yarn run crowdin:fix

- name: Configure Git
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
- name: Check for changes
id: changes
run: |
if git diff --quiet; then
echo "changes=false" >> $GITHUB_OUTPUT
else
echo "changes=true" >> $GITHUB_OUTPUT
fi
- name: Create and push changes to branch
if: steps.changes.outputs.changes == 'true'
run: |
BRANCH_NAME="crowdin-copy-changes"
git push origin --delete $BRANCH_NAME || true
git checkout -b $BRANCH_NAME
git add .
git commit -m "chore: Copy ignored files using crowdin:fix"
git push --force --set-upstream origin $BRANCH_NAME
echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV
- name: Install GitHub CLI
if: steps.changes.outputs.changes == 'true'
run: sudo apt-get install -y gh

- name: Create Pull Request
if: steps.changes.outputs.changes == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create --repo ${{ github.repository }} --base main --head ${{ env.branch_name }} --title "Copy ignored files using crowdin:fix" --body "This PR was created by GitHub Actions to copy ignored files using the crowdin:fix command."
37 changes: 37 additions & 0 deletions .github/workflows/download-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Crowdin Download Action

on:
workflow_dispatch:
### Schedule currently disabled ###
# schedule:
# - cron: '0 9 * * *'
# - cron: '0 13 * * *'
# - cron: '0 17 * * *'

permissions:
contents: write
pull-requests: write

jobs:
crowdin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Synchronize with Crowdin
uses: crowdin/github-action@v2
with:
upload_sources: false
upload_translations: false
download_translations: true
localization_branch_name: l10n_crowdin_translations

create_pull_request: true
pull_request_title: 'New Crowdin translations'
pull_request_body: 'New Crowdin pull request with translations'
pull_request_base_branch_name: 'main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: '669532'
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ jobs:
run: yarn check:mdx

- name: Build app
run: yarn build
run: yarn build --locale en


36 changes: 36 additions & 0 deletions .github/workflows/upload-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Crowdin Upload

on:
workflow_dispatch:
# push:
# branches: [ main ]

jobs:
crowdin-upload:
runs-on: ubuntu-latest
steps:
- name: Checkout Docs Repo
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install Dependencies
run: yarn --prefer-offline

- name: Write Translations
run: yarn write-translations

- name: Crowdin push
uses: crowdin/github-action@v2
with:
upload_sources: true
upload_translations: false
download_translations: false
env:
CROWDIN_PROJECT_ID: '669532'
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ yarn-error.log*
# non-production openrpc.json files
/openrpc/*openrpc.json

# Environment variables
.env

# translation files
i18n
stellar-cli-repo
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ RUN apt-get update && apt-get install --no-install-recommends -y gpg curl git ma
apt-get update && apt-get install -y nodejs yarn && apt-get clean

COPY . /app/
ARG CROWDIN_PERSONAL_TOKEN
ARG BUILD_TRANSLATIONS="False"

RUN yarn install
RUN yarn rpcspec:build
RUN yarn stellar-cli:build
RUN NODE_OPTIONS="--max-old-space-size=4096" yarn build

ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN if [ "$BUILD_TRANSLATIONS" = "True" ]; then \
CROWDIN_PERSONAL_TOKEN=${CROWDIN_PERSONAL_TOKEN} yarn build:production; \
else \
# In the preview build, we only want to build for English. Much quicker
yarn build; \
fi

FROM nginx:1.27

Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ LABEL ?= $(shell git rev-parse --short HEAD)$(and $(shell git status -s),-dirty-
TAG ?= stellar/stellar-docs:$(LABEL)
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
BUILD_DATE := $(shell date -u +%FT%TZ)
# If we're not in production, don't build translations
BUILD_TRANSLATIONS ?= "False"

docker-build:
$(SUDO) docker build --no-cache --pull --label org.opencontainers.image.created="$(BUILD_DATE)" -t $(TAG) .
$(SUDO) docker build --no-cache --pull --label org.opencontainers.image.created="$(BUILD_DATE)" -t $(TAG) . --build-arg CROWDIN_PERSONAL_TOKEN=${CROWDIN_PERSONAL_TOKEN} --build-arg BUILD_TRANSLATIONS=${BUILD_TRANSLATIONS}

docker-push:
$(SUDO) docker push $(TAG)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Anchor Platform provides an event service that sends HTTP webhook notifications
- Quote updates
- Customer KYC status changes

Event schemas for business servers are defined in the [API reference](/platforms/anchor-platform/next/api-reference/callbacks/post-event).
Event schemas for business servers are defined in the [API reference](../../api-reference/callbacks/post-event.api.mdx).

**Client Applications**

Expand All @@ -25,4 +25,4 @@ _Event schemas for client applications are defined in their respective SEPs:_
- [SEP-24 Transaction Events](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0024.md#single-historical-transaction)
- [SEP-31 Transaction Events](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0031.md#get-transaction)

This eliminates the need for business servers and client applications to continuously poll the APIs for updates.
This eliminates the need for business servers and client applications to continuously poll the APIs for updates.
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,6 @@ Works in the same manner as for the deposit flow. For more details, see [Transac

[sep-9]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0009.md
[sep-24]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0024.md
[event-handling]: /ap_versioned_docs/version-2.10/admin-guide/events/README.mdx
[rate-callback]: /ap_versioned_docs/version-2.10/api-reference/callbacks/README.mdx
[event-handling]: ../events/README.mdx
[rate-callback]: ../../api-reference/callbacks/README.mdx
[json-rpc-methods]: ../../api-reference/platform/rpc/methods/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ Works in the same manner as for the deposit flow. For more details, see [Transac
<Observer />

[sep-6]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md
[event-handling]: /ap_versioned_docs/version-2.10/admin-guide/events/README.mdx
[customer-callback]: /ap_versioned_docs/version-2.10/api-reference/callbacks/README.mdx
[rate-callback]: /ap_versioned_docs/version-2.10/api-reference/callbacks/README.mdx
[event-handling]: ../events/README.mdx
[customer-callback]: ../../api-reference/callbacks/README.mdx
[rate-callback]: ../../api-reference/callbacks/README.mdx
[get-transactions]: ../../api-reference/platform/transactions/get-transactions.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Anchor Platform provides an event service that sends HTTP webhook notifications
- Quote updates
- Customer KYC status changes

Event schemas for business servers are defined in the [API reference](/platforms/anchor-platform/next/api-reference/callbacks/post-event).
Event schemas for business servers are defined in the [API reference](../../api-reference/callbacks/post-event.api.mdx).

**Client Applications**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,6 @@ Works in the same manner as for the deposit flow. For more details, see [Transac

[sep-9]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0009.md
[sep-24]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0024.md
[event-handling]: /ap_versioned_docs/version-2.11/admin-guide/events/README.mdx
[rate-callback]: /ap_versioned_docs/version-2.11/api-reference/callbacks/README.mdx
[event-handling]: ../events/README.mdx
[rate-callback]: ../../api-reference/callbacks/README.mdx
[json-rpc-methods]: ../../api-reference/platform/rpc/methods/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ Works in the same manner as for the deposit flow. For more details, see [Transac
<Observer />

[sep-6]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md
[event-handling]: /ap_versioned_docs/version-2.11/admin-guide/events/README.mdx
[customer-callback]: /ap_versioned_docs/version-2.11/api-reference/callbacks/README.mdx
[rate-callback]: /ap_versioned_docs/version-2.11/api-reference/callbacks/README.mdx
[event-handling]: ../events/README.mdx
[customer-callback]: ../../api-reference/callbacks/README.mdx
[rate-callback]: ../../api-reference/callbacks/README.mdx
[get-transactions]: ../../api-reference/platform/transactions/get-transactions.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Anchor Platform provides an event service that sends HTTP webhook notifications
- Quote updates
- Customer KYC status changes

Event schemas for business servers are defined in the [API reference](/ap_versioned_docs/version-2.8/api-reference/callbacks/post-event.api.mdx).
Event schemas for business servers are defined in the [API reference](../../api-reference/callbacks/post-event.api.mdx).

**Client Applications**

Expand All @@ -25,4 +25,4 @@ _Event schemas for client applications are defined in their respective SEPs:_
- [SEP-24 Transaction Events](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0024.md#single-historical-transaction)
- [SEP-31 Transaction Events](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0031.md#get-transaction)

This eliminates the need for business servers and client applications to continuously poll the APIs for updates.
This eliminates the need for business servers and client applications to continuously poll the APIs for updates.
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,6 @@ Works in the same manner as for the deposit flow. For more details, see [Transac

[sep-9]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0009.md
[sep-24]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0024.md
[event-handling]: /ap_versioned_docs/version-2.8/admin-guide/events/README.mdx
[rate-callback]: /ap_versioned_docs/version-2.8/api-reference/callbacks/README.mdx
[event-handling]: ../events/README.mdx
[rate-callback]: ../../api-reference/callbacks/README.mdx
[json-rpc-methods]: ../../api-reference/platform/rpc/methods/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ Works in the same manner as for the deposit flow. For more details, see [Transac
<Observer />

[sep-6]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md
[event-handling]: /ap_versioned_docs/version-2.8/admin-guide/events/README.mdx
[customer-callback]: /ap_versioned_docs/version-2.8/api-reference/callbacks/README.mdx
[rate-callback]: /ap_versioned_docs/version-2.8/api-reference/callbacks/README.mdx
[event-handling]: ../events/README.mdx
[customer-callback]: ../../api-reference/callbacks/README.mdx
[rate-callback]: ../../api-reference/callbacks/README.mdx
[get-transactions]: ../../api-reference/platform/transactions/get-transactions.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Anchor Platform provides an event service that sends HTTP webhook notifications
- Quote updates
- Customer KYC status changes

Event schemas for business servers are defined in the [API reference](/platforms/anchor-platform/next/api-reference/callbacks/post-event).
Event schemas for business servers are defined in the [API reference](../../api-reference/callbacks/post-event.api.mdx).

**Client Applications**

Expand All @@ -25,4 +25,4 @@ _Event schemas for client applications are defined in their respective SEPs:_
- [SEP-24 Transaction Events](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0024.md#single-historical-transaction)
- [SEP-31 Transaction Events](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0031.md#get-transaction)

This eliminates the need for business servers and client applications to continuously poll the APIs for updates.
This eliminates the need for business servers and client applications to continuously poll the APIs for updates.
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,6 @@ Works in the same manner as for the deposit flow. For more details, see [Transac

[sep-9]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0009.md
[sep-24]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0024.md
[event-handling]: /ap_versioned_docs/version-2.9/admin-guide/events/README.mdx
[rate-callback]: /ap_versioned_docs/version-2.9/api-reference/callbacks/README.mdx
[event-handling]: ../events/README.mdx
[rate-callback]: ../../api-reference/callbacks/README.mdx
[json-rpc-methods]: ../../api-reference/platform/rpc/methods/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ Works in the same manner as for the deposit flow. For more details, see [Transac
<Observer />

[sep-6]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md
[event-handling]: /ap_versioned_docs/version-2.9/admin-guide/events/README.mdx
[customer-callback]: /ap_versioned_docs/version-2.9/api-reference/callbacks/README.mdx
[rate-callback]: /ap_versioned_docs/version-2.9/api-reference/callbacks/README.mdx
[event-handling]: ../events/README.mdx
[customer-callback]: ../../api-reference/callbacks/README.mdx
[rate-callback]: ../../api-reference/callbacks/README.mdx
[get-transactions]: ../../api-reference/platform/transactions/get-transactions.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Anchor Platform provides an event service that sends HTTP webhook notifications
- Quote updates
- Customer KYC status changes

Event schemas for business servers are defined in the [API reference](/platforms/anchor-platform/next/api-reference/callbacks/post-event).
Event schemas for business servers are defined in the [API reference](../../api-reference/callbacks/post-event.api.mdx).

**Client Applications**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,6 @@ Works in the same manner as for the deposit flow. For more details, see [Transac

[sep-9]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0009.md
[sep-24]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0024.md
[event-handling]: /platforms/anchor-platform/admin-guide/events/README.mdx
[rate-callback]: /platforms/anchor-platform/api-reference/callbacks/README.mdx
[event-handling]: ../events/README.mdx
[rate-callback]: ../../api-reference/callbacks/README.mdx
[json-rpc-methods]: ../../api-reference/platform/rpc/methods/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ Works in the same manner as for the deposit flow. For more details, see [Transac
<Observer />

[sep-6]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md
[event-handling]: /platforms/anchor-platform/admin-guide/events/README.mdx
[customer-callback]: /platforms/anchor-platform/api-reference/callbacks/README.mdx
[rate-callback]: /platforms/anchor-platform/api-reference/callbacks/README.mdx
[event-handling]: ../events/README.mdx
[customer-callback]: ../../api-reference/callbacks/README.mdx
[rate-callback]: ../../api-reference/callbacks/README.mdx
[get-transactions]: ../../api-reference/platform/transactions/get-transactions.api.mdx
4 changes: 3 additions & 1 deletion config/anchorPlatform.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { PluginConfig } from '@docusaurus/types';
import versions from '../ap_versions.json'
import { makeEditUrl } from './constants';

import type * as Plugin from '@docusaurus/types/src/plugin';
import type * as OpenApiPlugin from 'docusaurus-plugin-openapi-docs';
import type { APIVersionOptions } from 'docusaurus-plugin-openapi-docs/src/types';
Expand Down Expand Up @@ -54,7 +56,7 @@ export const anchorPlatformPluginInstances: PluginConfig[] = [
routeBasePath: "/platforms/anchor-platform",
docItemComponent: "@theme/ApiItem",
sidebarPath: "config/anchorPlatform.sidebar.ts",
editUrl: "https://github.com/stellar/stellar-docs/tree/main",
editUrl: makeEditUrl,
exclude: ['**/component/**', '**/README.md'],
showLastUpdateTime: true,
showLastUpdateAuthor: true,
Expand Down
11 changes: 11 additions & 0 deletions config/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const DEFAULT_LOCALE: string = 'en';
export const LOCALE_FULL_CODE: Record<string, string> = {
es: 'es-ES',
};

export const makeEditUrl = ({ locale, versionDocsDirPath, docPath }) => {
if (locale !== DEFAULT_LOCALE) {
return `https://crowdin.com/project/stellar-dev-docs/${LOCALE_FULL_CODE[locale]}`
}
return `https://github.com/stellar/stellar-docs/edit/main/${versionDocsDirPath}/${docPath}`
};
Loading

0 comments on commit 029ed2e

Please sign in to comment.